Skip to content

Merge pull request #67 from MatrixAI/feature-flake-indirect #11

Merge pull request #67 from MatrixAI/feature-flake-indirect

Merge pull request #67 from MatrixAI/feature-flake-indirect #11

Workflow file for this run

name: CI
on:
push:
branches:
- staging
- feature*
jobs:
check-lint:
name: "Check / Lint"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
steps:
- uses: actions/checkout@v4
- name: Run linting
run: |
nix develop --command bash -c $'
npm run lint
npm run lint-shell
'
check-test:
name: "Check / Test"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
steps:
- uses: actions/checkout@v4
- name: Run tests
run: |
nix develop .#ci --command bash -c $'
npm test -- --ci --coverage
'
- uses: actions/upload-artifact@v4
with:
name: coverage-report
path: tmp/coverage/cobertura-coverage.xml
build-pull:
name: "Build / Pull Request"
runs-on: ubuntu-latest
needs: [check-lint, check-test]
if: github.ref == 'refs/heads/staging'
steps:
- uses: actions/checkout@v4
- name: Create pull request
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
gh pr create \
--head staging \
--base master \
--title "ci: merge staging to master" \
--body "This is an automatic PR generated by the CI/CD pipeline. This will be automatically fast-forward merged if successful." \
--assignee "@me" \
--no-maintainer-edit || true
printf "Pipeline Attempt on $GITHUB_RUN_ID for $GITHUB_SHA\n\n$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
| gh pr comment staging \
--body-file - \
--repo "$GITHUB_REPOSITORY"
build-dist:
name: "Build / Dist"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
needs: [check-lint, check-test]
if: github.ref == 'refs/heads/staging'
steps:
- uses: actions/checkout@v4
- run: |
nix develop .#ci --command bash -c $'
npm run build --ignore-scripts --verbose
'
- uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist
build-platforms:
name: "Build / Platforms"
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.platform == 'linux' && 'ghcr.io/matrixai/github-runner' || null }}
needs: build-dist
if: github.ref == 'refs/heads/staging'
strategy:
fail-fast: false
matrix:
include:
- platform: linux
os: ubuntu-latest
script: |
nix develop .#ci --command bash -c $'
npm test -- --ci --coverage
npm run bench
'
- platform: windows
os: windows-latest
script: |
./scripts/choco-install.ps1
refreshenv
npm install --ignore-scripts
$env:Path = "$(npm root)\.bin;" + $env:Path
npm test -- --ci --coverage
npm run bench
- platform: macos
os: macos-latest
script: |
eval "$(brew shellenv)"
./scripts/brew-install.sh
hash -r
npm install --ignore-scripts
export PATH="$(npm root)/.bin:$PATH"
npm test -- --ci --coverage
npm run bench
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/download-artifact@v4
with:
name: dist
path: ./dist
- name: Build
run: ${{ matrix.script }}
- uses: actions/upload-artifact@v4
with:
name: builds-${{ matrix.platform }}
path: ./builds
build-prerelease:
name: "Build / Pre-release"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
concurrency:
group: build-prerelease
cancel-in-progress: false
needs: [check-lint, check-test]
if: >
github.ref == 'refs/heads/staging' &&
startsWith(github.ref, 'refs/tags/v') &&
contains(github.ref, '-')
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: builds*
path: builds
merge-multiple: true
- name: Run pre-release
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
echo 'Publishing library prerelease'
nix develop .#ci --command bash -c $'
npm publish --tag prerelease --access public
'
rm -f ./.npmrc
integration-merge:
name: "Integration / Merge"
runs-on: ubuntu-latest
concurrency:
group: integration-merge
cancel-in-progress: true
needs: [build-pull, build-platforms]
if: github.ref == 'refs/heads/staging'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Merge into master
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
run: |
printf "Pipeline Succeeded on $GITHUB_RUN_ID for $GITHUB_SHA\n\n$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
| gh pr comment staging \
--body-file - \
--repo "$GITHUB_REPOSITORY"
git checkout master
git merge --ff-only "$GITHUB_SHA"
git push origin master
release-distribution:
name: "Release / Distribution"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
concurrency:
group: release-distribution
cancel-in-progress: false
needs: integration-merge
if: >
github.ref == 'refs/heads/staging' &&
startsWith(github.ref, 'refs/tags/v') &&
!contains(github.ref, '-')
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: builds*
path: builds
merge-multiple: true
- name: Run release
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
echo 'Publishing library'
nix develop .#ci --command bash -c $'
npm publish --access public
'
rm -f ./.npmrc