Skip to content

Commit

Permalink
build: rewrite ci
Browse files Browse the repository at this point in the history
Co-authored-by: Shahar "Dawn" Or <[email protected]>
  • Loading branch information
rostislav-simonik and mightyiam committed Aug 12, 2023
1 parent 5d4c25f commit eb4ec10
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
60 changes: 34 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
name: 'ci'

on:
push:
branches: [master]
pull_request:
branches: [master]
pull_request: {}
push: {}

jobs:
# The ci-matrix job ends up as multiple jobs and therefore as multiple checks.
# Each check's name ends up with the node version appended.
# If we were to use those checks as required checks, we would have to occasionally bump them.
# This job allows us to have a single check that we don't have to bump.
ci:
runs-on: 'ubuntu-latest'
needs: ci-matrix
runs-on: ubuntu-latest
steps:
- uses: 'actions/checkout@v3'

- name: 'Use Node.js'
uses: 'actions/setup-node@v3'
- run: exit 0
ci-matrix:
needs: get-supported-node-versions
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ${{ fromJson(needs.get-supported-node-versions.outputs.versions) }}
steps:
- uses: actions/checkout@v3
with:
node-version: 'lts/*'

- name: 'Cache Node dependencies'
uses: 'actions/[email protected]'
fetch-depth: 0 # for commit linting
- uses: actions/setup-node@v3
with:
path: '~/.npm'
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: 'Install dependencies'
run: 'npm install'

node-version: ${{ matrix.node-version }}
- run: npm --global install npm@latest
- run: npm ci
- uses: wagoid/commitlint-github-action@v5

- name: 'Run tests'
run: 'npm test'
- run: npm test
get-supported-node-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: get
run: |
set -euxo pipefail
active_versions=$(bash get-node-supported-versions.sh)
echo "active=$active_versions" >> "$GITHUB_OUTPUT"
outputs:
versions: ${{ steps.get.outputs.active }}
7 changes: 7 additions & 0 deletions get-node-supported-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euxo pipefail
url=https://raw.githubusercontent.com/nodejs/Release/master/schedule.json
release_schedule=$(curl -s $url)
today=$(date "+%Y-%m-%d")
active_versions=$(echo $release_schedule | jq -s "[ .[] | to_entries[] | select(.value.start <= \"$today\" and .value.end >= \"$today\") | .key[1:] ]")
echo $active_versions

0 comments on commit eb4ec10

Please sign in to comment.