ODK Web Forms CI #15
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: 'ci' | |
run-name: 'ODK Web Forms CI' | |
on: | |
workflow_dispatch: | |
push: | |
merge_group: | |
pull_request: | |
paths-ignore: | |
- ".vscode/**" | |
- "**/*.md" | |
- ".github/ISSUE_TEMPLATE/**" | |
# Automatically cancel older in-progress jobs on the same branch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
changes: | |
runs-on: 'ubuntu-latest' | |
outputs: | |
root: ${{ steps.changes.outputs.root }} | |
odk-web-forms: ${{ steps.changes.outputs.odk-web-forms }} | |
tree-sitter-xpath: ${{ steps.changes.outputs.tree-sitter-xpath }} | |
steps: | |
- uses: 'actions/checkout@v3' | |
- uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
root: | |
- '*' | |
- '.github/workflows/*' | |
odk-web-forms: | |
- 'packages/odk-web-forms/**' | |
tree-sitter-xpath: | |
- 'packages/tree-sitter-xpath/grammar.ts' | |
- 'packages/tree-sitter-xpath/scripts/**' | |
- 'packages/tree-sitter-xpath/test/**' | |
# So the `paths-filter` action doesn't attempt to use the GitHub API | |
# when run on pull requests | |
token: '' | |
install-and-build: | |
runs-on: 'ubuntu-latest' | |
strategy: | |
matrix: | |
node-version: ['18.18.1', '20.8.0'] | |
steps: | |
- uses: 'actions/checkout@v3' | |
- uses: 'volta-cli/action@v4' | |
with: | |
node-version: '${{ matrix.node-version }}' | |
yarn-version: '1.22.19' | |
- uses: 'actions/cache@v3' | |
id: cache-install | |
with: | |
path: | | |
~/.cache/ms-playwright | |
node_modules | |
**/node_modules | |
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }} | |
- uses: 'actions/cache@v3' | |
id: cache-build | |
with: | |
# Note: the tree-sitter-xpath .js and .wasm paths are standard for | |
# tree-sitter's build output. They also litter a bunch of other files | |
# in various build phases, several under `src` (which is why the | |
# grammar's TypeScript source is not there). | |
path: | | |
examples/*/dist | |
packages/*/dist | |
packages/tree-sitter-xpath/grammar.js | |
packages/tree-sitter-xpath/tree-sitter-xpath.wasm | |
packages/tree-sitter-xpath/types | |
key: build-${{ matrix.node-version }}-${{ github.sha }} | |
- if: steps.cache-install.outputs.cache-hit != 'true' && matrix.node-version != '20.8.0' | |
run: 'yarn install --frozen-lockfile' | |
- if: steps.cache-install.outputs.cache-hit != 'true' && matrix.node-version == '20.8.0' | |
run: 'yarn install --frozen-lockfile && yarn playwright install chromium firefox webkit' | |
- run: 'yarn build' | |
lint: | |
needs: ['install-and-build', 'changes'] | |
runs-on: 'ubuntu-latest' | |
strategy: | |
matrix: | |
node-version: ['20.8.0'] | |
steps: | |
- uses: 'actions/checkout@v3' | |
- uses: 'volta-cli/action@v4' | |
with: | |
node-version: '${{ matrix.node-version }}' | |
yarn-version: '1.22.19' | |
- uses: 'actions/cache@v3' | |
id: cache-install | |
with: | |
path: | | |
~/.cache/ms-playwright | |
node_modules | |
**/node_modules | |
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }} | |
fail-on-cache-miss: true | |
- uses: 'actions/cache@v3' | |
id: cache-build | |
with: | |
path: | | |
examples/*/dist | |
packages/*/dist | |
packages/tree-sitter-xpath/grammar.js | |
packages/tree-sitter-xpath/tree-sitter-xpath.wasm | |
packages/tree-sitter-xpath/types | |
key: build-${{ matrix.node-version }}-${{ github.sha }} | |
fail-on-cache-miss: true | |
- run: 'yarn lint' | |
test-odk-web-forms: | |
needs: ['install-and-build', 'changes'] | |
if: needs.changes.outputs.root == 'true' || needs.changes.outputs.odk-web-forms == 'true' | |
runs-on: 'ubuntu-latest' | |
strategy: | |
matrix: | |
node-version: ['18.18.1', '20.8.0'] | |
steps: | |
- uses: 'actions/checkout@v3' | |
- uses: 'volta-cli/action@v4' | |
with: | |
node-version: '${{ matrix.node-version }}' | |
yarn-version: '1.22.19' | |
- uses: 'actions/cache@v3' | |
id: cache-install | |
with: | |
path: | | |
~/.cache/ms-playwright | |
node_modules | |
**/node_modules | |
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }} | |
fail-on-cache-miss: true | |
- uses: 'actions/cache@v3' | |
id: cache-build | |
with: | |
path: | | |
examples/*/dist | |
packages/*/dist | |
packages/tree-sitter-xpath/grammar.js | |
packages/tree-sitter-xpath/tree-sitter-xpath.wasm | |
packages/tree-sitter-xpath/types | |
key: build-${{ matrix.node-version }}-${{ github.sha }} | |
fail-on-cache-miss: true | |
- run: 'yarn workspace @odk/web-forms test' | |
test-tree-sitter-xpath: | |
needs: ['install-and-build', 'changes'] | |
if: needs.changes.outputs.root == 'true' || needs.changes.outputs.tree-sitter-xpath == 'true' | |
runs-on: 'ubuntu-latest' | |
strategy: | |
matrix: | |
node-version: ['18.18.1', '20.8.0'] | |
steps: | |
- uses: 'actions/checkout@v3' | |
- uses: 'volta-cli/action@v4' | |
with: | |
node-version: '${{ matrix.node-version }}' | |
yarn-version: '1.22.19' | |
- uses: 'actions/cache@v3' | |
id: cache-install | |
with: | |
path: | | |
~/.cache/ms-playwright | |
node_modules | |
**/node_modules | |
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }} | |
fail-on-cache-miss: true | |
- uses: 'actions/cache@v3' | |
id: cache-build | |
with: | |
path: | | |
examples/*/dist | |
packages/*/dist | |
packages/tree-sitter-xpath/grammar.js | |
packages/tree-sitter-xpath/tree-sitter-xpath.wasm | |
packages/tree-sitter-xpath/types | |
key: build-${{ matrix.node-version }}-${{ github.sha }} | |
fail-on-cache-miss: true | |
- run: 'yarn workspace tree-sitter-xpath build' | |
- run: 'yarn workspace tree-sitter-xpath test' |