# main only name: Integrate on: push: branches: [main] env: FORCE_COLOR: 1 jobs: linuxNode14: name: "[Linux] Node.js v14: Unit tests" runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 - name: Retrieve dependencies from cache id: cacheNpm uses: actions/cache@v2 with: path: | ~/.npm node_modules key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v1 with: node-version: 14.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' run: | npm update --no-save npm update --save-dev --no-save - name: Unit tests run: npm test -- -b windowsNode14: name: "[Windows] Node.js v14: Unit tests" runs-on: windows-latest steps: - name: Checkout repository uses: actions/checkout@v2 - name: Retrieve dependencies from cache id: cacheNpm uses: actions/cache@v2 with: path: | ~/.npm node_modules key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v1 with: node-version: 14.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' run: | npm update --no-save npm update --save-dev --no-save - name: Unit tests run: npm test -- -b linuxNode16: name: "[Linux] Node.js 16: Unit tests on npm package" runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 - name: Retrieve dependencies from cache id: cacheNpm uses: actions/cache@v2 with: path: | ~/.npm node_modules key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: npm-v16-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v1 with: node-version: 16.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' run: | npm update --no-save npm update --save-dev --no-save - name: Build local package run: npm pack - name: Unit tests on npm package run: | NAME=`cat package.json | grep '"name": "' | grep -oE ": .*" | grep -oE '[^: ",]+'` VERSION=`cat package.json | grep '"version": "' | grep -oE ": .*" | grep -oE '[^: ",]+'` tar zxf "${NAME}-${VERSION}.tgz" cp -R test "package" ln -s "$(pwd)"/node_modules "package/node_modules" cd "package" npm test -- -b linuxNode12: name: "[Linux] Node.js v12: Unit tests with coverage" runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 - name: Retrieve dependencies from cache id: cacheNpm uses: actions/cache@v2 with: path: | ~/.npm node_modules key: npm-v12-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: npm-v12-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v1 with: node-version: 12.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' run: | npm update --no-save npm update --save-dev --no-save - name: Unit tests run: npm run coverage - name: Push coverage run: npx codecov tagIfNewVersion: name: Tag if new version runs-on: ubuntu-latest needs: [linuxNode14, linuxNode12, linuxNode16, windowsNode14] steps: - name: Checkout repository uses: actions/checkout@v2 with: # Ensure to have complete history of commits pushed with given push operation # It's loose and imperfect assumption that no more than 30 commits will be pushed at once fetch-depth: 30 # Tag needs to be pushed with real user token, otherwise pushed tag won't trigger the actions workflow # Hence we're passing 'serverless-ci' user authentication token token: ${{ secrets.USER_GITHUB_TOKEN }} - name: Tag if new version if: github.event.before != '0000000000000000000000000000000000000000' # Skip on first commit run: | NEW_VERSION=`git diff -U0 ${{ github.event.before }} package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : if [ -n "$NEW_VERSION" ]; then git tag v$NEW_VERSION git push --tags fi