Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Improve Github Actions (#7)
Browse files Browse the repository at this point in the history
* ci: Stop setting CI branch

* ci: try to see if there is any branch reference in env

* ci: fix env logging

* ci: actually fix bundlewatch branchname

* ci: Update name of bundlewatch step and build job

* ci: clean up CI with naming steps somewhat

* ci: cleanup yaml a bit by setting CI: true in all jobs instead of in steps

* ci: Improve caching of npm

* ci: make naming of build job the same as test job
  • Loading branch information
oBusk authored Mar 3, 2020
1 parent 7e2061f commit ead81f0
Showing 1 changed file with 93 additions and 61 deletions.
154 changes: 93 additions & 61 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,121 +6,153 @@ jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 13x
uses: actions/setup-node@v1
with:
node-version: 13.x
- name: Cache node modules
- name: Get cache dir, Node Version and NPM Version
id: node-config
run: |
echo "::set-output name=nodev::$(node -v)"
echo "::set-output name=npmv::$(npm -v)"
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm cache
uses: actions/cache@v1
env:
node-version: 13.x
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node-${{ env.node-version }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-${{ env.node-version }}-npm-cache-
- run: npm ci
env:
CI: true
- run: npm run lint
env:
CI: true
path: ${{ steps.node-config.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-npm-${{ steps.node-config.outputs.npmv }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-npm-${{ steps.node-config.outputs.npmv }}-
${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-
${{ runner.os }}-
- name: Install
run: npm ci
- name: Check Linting
run: npm run lint

test:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true

strategy:
matrix:
node-version: [10.16.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
- name: Get cache dir, Node Version and NPM Version
id: node-config
run: |
echo "::set-output name=nodev::$(node -v)"
echo "::set-output name=npmv::$(npm -v)"
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm cache
uses: actions/cache@v1
env:
node-version: ${{ matrix.node-version }}
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node-${{ env.node-version }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-${{ env.node-version }}-npm-cache-
- run: npm ci
env:
CI: true
- run: npm run build
env:
CI: true
- run: npm test
env:
CI: true
path: ${{ steps.node-config.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-npm-${{ steps.node-config.outputs.npmv }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-npm-${{ steps.node-config.outputs.npmv }}-
${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-
${{ runner.os }}-
- name: Install
run: npm ci
- name: Run Tests
run: npm run test-coverage

test-with-codecov:
name: test (13.x) [With codecov]
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v2
- name: Use Node.js 13x
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 13.x
uses: actions/setup-node@v1
with:
node-version: 13.x
- name: Cache node modules
- name: Get cache dir, Node Version and NPM Version
id: node-config
run: |
echo "::set-output name=nodev::$(node -v)"
echo "::set-output name=npmv::$(npm -v)"
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm cache
uses: actions/cache@v1
env:
node-version: 13.x
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node-${{ env.node-version }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-${{ env.node-version }}-npm-cache-
- run: npm ci
env:
CI: true
- run: npm run build
env:
CI: true
- run: npm run test-coverage
env:
CI: true
path: ${{ steps.node-config.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-npm-${{ steps.node-config.outputs.npmv }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-npm-${{ steps.node-config.outputs.npmv }}-
${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-
${{ runner.os }}-
- name: Install
run: npm ci
- name: Run Tests
run: npm run test-coverage
- name: Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

bundlesize:
build-with-bundlewatch:
name: build (13.x) [With bundlewatch]
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true

steps:
- uses: actions/checkout@v2
- name: Use Node.js 13x
uses: actions/setup-node@v1
with:
node-version: 13.x
- name: Cache node modules
- name: Get cache dir, Node Version and NPM Version
id: node-config
run: |
echo "::set-output name=nodev::$(node -v)"
echo "::set-output name=npmv::$(npm -v)"
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm cache
uses: actions/cache@v1
env:
node-version: 13.x
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node-${{ env.node-version }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-${{ env.node-version }}-npm-cache-
- run: npm ci
env:
CI: true
- run: npm run build
env:
CI: true
- run: npm run bundlewatch
path: ${{ steps.node-config.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-npm-${{ steps.node-config.outputs.npmv }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-npm-${{ steps.node-config.outputs.npmv }}-
${{ runner.os }}-node-${{ steps.node-config.outputs.nodev }}-
${{ runner.os }}-
- name: Install
run: npm ci
- name: Build
run: npm run build
# TODO: remove after https://github.com/bundlewatch/bundlewatch/pull/66 is merged and released
# https://stackoverflow.com/a/58035262
- name: Extract the branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Check and Report Bundlesize
run: npm run bundlewatch
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
# TODO: remove after https://github.com/bundlewatch/bundlewatch/pull/66 is merged and released
CI_REPO_OWNER: "oBusk"
CI_REPO_NAME: "read-bigint"
CI_COMMIT_SHA: ${{ github.sha }}
CI_BRANCH: ${{ github.ref }}
CI_BRANCH: ${{ steps.extract_branch.outputs.branch }}

0 comments on commit ead81f0

Please sign in to comment.