Pre-commit demo #281
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: authzed-node-ci | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "*" | |
merge_group: | |
types: | |
- "checks_requested" | |
release: | |
types: [published] | |
jobs: | |
paths-filter: | |
runs-on: "buildjet-2vcpu-ubuntu-2204" | |
outputs: | |
codechange: "${{ steps.code-filter.outputs.codechange }}" | |
steps: | |
- uses: "actions/checkout@v4" | |
- uses: "dorny/paths-filter@v3" | |
id: "code-filter" | |
with: | |
filters: | | |
codechange: | |
- src/** | |
- .github/workflows/authzed-node.yaml | |
- package.json | |
- js-dist/package.json | |
- buf.gen.yaml | |
test: | |
name: Run Tests | |
runs-on: "buildjet-2vcpu-ubuntu-2204" | |
strategy: | |
matrix: | |
node-version: [18, 20, 21] | |
needs: "paths-filter" | |
if: | | |
needs.paths-filter.outputs.codechange == 'true' || github.event_name == 'release' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: "authzed/action-spicedb@v1" | |
with: | |
version: "latest" | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "yarn" | |
- name: "Yarn install" | |
run: yarn install --frozen-lockfile | |
- name: Run Yarn tests | |
run: CI=true yarn only-run-tests | |
working-directory: ./ | |
lint: | |
name: Lint | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: "actions/checkout@v4" | |
- uses: "actions/setup-python@v5" | |
# NOTE: this is needed for installing and then running tsc, | |
# which is invoked locally by pre-commit | |
- uses: "actions/setup-node@v4" | |
with: | |
cache: "yarn" | |
- name: "Yarn install" | |
run: yarn install --frozen-lockfile | |
- uses: "pre-commit/action@v3.0.1" | |
publish-npm: | |
name: Publish to NPM | |
needs: | |
- test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- uses: bahmutov/npm-install@v1 | |
with: | |
install-command: yarn --frozen-lockfile --silent | |
working-directory: ./ | |
- run: yarn test | |
- uses: battila7/get-version-action@v2 | |
- uses: JS-DevTools/npm-publish@v3 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
tag: ${{ steps.get_version.outputs.version }} | |
access: public | |
build-js-client: | |
name: Build and Test JS client | |
runs-on: "buildjet-2vcpu-ubuntu-2204" | |
strategy: | |
matrix: | |
node-version: [18, 20, 21] | |
needs: "paths-filter" | |
if: | | |
needs.paths-filter.outputs.codechange == 'true' || github.event_name == 'release' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: "authzed/action-spicedb@v1" | |
with: | |
version: "latest" | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- uses: bahmutov/npm-install@v1 | |
with: | |
install-command: yarn --frozen-lockfile --silent | |
working-directory: ./ | |
- name: Run build | |
run: yarn build-js-client | |
working-directory: ./ | |
- uses: bahmutov/npm-install@v1 | |
with: | |
install-command: yarn --frozen-lockfile --silent | |
working-directory: ./js-dist | |
- name: Run tests | |
run: CI=true yarn only-run-tests | |
working-directory: ./js-dist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: js-client-${{ matrix.node-version }} | |
path: | | |
js-dist/** | |
!js-dist/node_modules/** | |
publish-js-client-npm: | |
name: Publish JS client to NPM | |
needs: build-js-client | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' | |
steps: | |
- name: Download js client build | |
uses: actions/download-artifact@v4 | |
with: | |
name: js-client-18 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- uses: bahmutov/npm-install@v1 | |
with: | |
install-command: yarn --frozen-lockfile --silent | |
working-directory: ./ | |
- uses: battila7/get-version-action@v2 | |
- uses: JS-DevTools/npm-publish@v3 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
tag: ${{ steps.get_version.outputs.version }} | |
access: public |