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

CI Integration #65

Merged
merged 1 commit into from
Jul 2, 2024
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
220 changes: 220 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
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
env: ${{ matrix.env }}
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
- 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
23 changes: 0 additions & 23 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

Loading