@@ -10,26 +10,47 @@ jobs:
1010 serverless-localstack-test :
1111 name : Serverless LocalStack CI
1212 runs-on : ubuntu-latest
13+ strategy :
14+ matrix :
15+ sls-major-version : ["2", "3"]
1316 steps :
1417 - name : Checkout repository
1518 uses : actions/checkout@v3
1619
1720 - name : Setup NodeJS
18- uses : actions/setup-node@v2
21+ uses : actions/setup-node@v3
1922 with :
20- node-version : ' 12 '
23+ node-version : ' 18 '
2124
2225 - name : Cache node modules
23- uses : actions/cache@v2
26+ uses : actions/cache@v3
2427 env :
25- cache-name : cache-node-modules
28+ cache-name : cache-node-modules-v${{ matrix.sls-major-version }}
2629 with :
2730 path : ~/.npm
28- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
31+ key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.sls-major-version }}-${{ hashFiles('**/package-lock.json') }}
2932 restore-keys : |
30- ${{ runner.os }}-build-${{ env.cache-name }}-
31- ${{ runner.os }}-build-
32- ${{ runner.os }}-
33+ ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.sls-major-version }}-
34+
35+ - name : Install deps
36+ run : |
37+ npm install
38+
39+ - name : Update SLS version to v3
40+ if : ${{ matrix.sls-major-version == '3' }}
41+ run : |
42+ npm install serverless@3
43+
44+ - name : Check installed version
45+ env :
46+ EXPECTED_SLS_MAJOR_VERSION : ${{ matrix.sls-major-version }}
47+ run : |
48+ installed_sls_version=$(npm list | grep serverless@ | sed -E 's/.*serverless@(.*)/\1/')
49+ echo "installed serverless version: ${installed_sls_version}"
50+ if [ "${installed_sls_version:0:1}" != ${EXPECTED_SLS_MAJOR_VERSION} ]; then
51+ echo "expected version ${EXPECTED_SLS_MAJOR_VERSION}, but installed ${installed_sls_version}"
52+ exit 1
53+ fi
3354
3455 - name : Start LocalStack
3556 run : |
3859 localstack start -d
3960 localstack wait -t 30
4061
41- - name : Install deps
42- run : |
43- npm ci
44-
4562 - name : Run Lint and Test
4663 run : |
4764 set -e
0 commit comments