Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: rewrite ci #294

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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