Skip to content

Commit

Permalink
CI update: node 18 + run tests for serverless v2 and v3 (#220)
Browse files Browse the repository at this point in the history
Co-authored-by: Waldemar Hummer <[email protected]>
  • Loading branch information
steffyP and whummer authored May 16, 2023
1 parent 102fe13 commit 26b4dc5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,47 @@ jobs:
serverless-localstack-test:
name: Serverless LocalStack CI
runs-on: ubuntu-latest
strategy:
matrix:
sls-major-version: ["2", "3"]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup NodeJS
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '12'
node-version: '18'

- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-node-modules
cache-name: cache-node-modules-v${{ matrix.sls-major-version }}
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.sls-major-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.sls-major-version }}-
- name: Install deps
run: |
npm install
- name: Update SLS version to v3
if: ${{ matrix.sls-major-version == '3' }}
run: |
npm install serverless@3
- name: Check installed version
env:
EXPECTED_SLS_MAJOR_VERSION: ${{ matrix.sls-major-version }}
run : |
installed_sls_version=$(npm list | grep serverless@ | sed -E 's/.*serverless@(.*)/\1/')
echo "installed serverless version: ${installed_sls_version}"
if [ "${installed_sls_version:0:1}" != ${EXPECTED_SLS_MAJOR_VERSION} ]; then
echo "expected version ${EXPECTED_SLS_MAJOR_VERSION}, but installed ${installed_sls_version}"
exit 1
fi
- name: Start LocalStack
run: |
Expand All @@ -38,10 +59,6 @@ jobs:
localstack start -d
localstack wait -t 30
- name: Install deps
run: |
npm ci
- name: Run Lint and Test
run: |
set -e
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"test:watch": "JASMINE_CONFIG_PATH=spec/support/jasmine.json jasmine",
"test:integration": "JASMINE_CONFIG_PATH=spec/support/jasmine_integration.json jasmine",
"test:integration:watch": "JASMINE_CONFIG_PATH=spec/support/jasmine_integration.json nodemon -L -i spec/integrate ./node_modules/.bin/jasmine",
"test:cover": "jasmine --coverage",
"prepublish": "npm run test",
"preversion": "npm run test"
"test:cover": "jasmine --coverage"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const AWS = require('aws-sdk');
// Set the region and endpoint in the config for LocalStack
AWS.config.update({
region: 'us-east-1',
endpoint: 'http://localhost:4566'
endpoint: 'http://127.0.0.1:4566'
});
AWS.config.credentials = new AWS.Credentials({
accessKeyId: 'test',
Expand Down
5 changes: 3 additions & 2 deletions spec/unit/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("LocalstackPlugin", () => {

beforeEach(() => {
sandbox = sinon.createSandbox();
serverless = new Serverless();
serverless = new Serverless({commands: ['deploy'], options: {}});
awsProvider = new AwsProvider(serverless, {});
awsConfig = new AWS.Config();
AWS.config = awsConfig;
Expand Down Expand Up @@ -176,7 +176,8 @@ describe("LocalstackPlugin", () => {
});
expect(request.called).to.be.true;
let templateUrl = request.firstCall.args[2].TemplateURL;
expect(templateUrl).to.startsWith(`${config.host}`);
// url should either start with 'http://localhost' or 'http://127.0.0.1
expect(templateUrl).to.satisfy((url) => url.startsWith(`${config.host}`) || url.startsWith('http://127.0.0.1'));
});

it('should not send validateTemplate calls to localstack', async () => {
Expand Down

0 comments on commit 26b4dc5

Please sign in to comment.