Repository navigation
ci: switch GitHub Actions to devenv #28
Workflow file for this run
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| # dorny/paths-filter calls the GitHub PR-files API to enumerate | |
| # changed files on a pull request. On private repos that endpoint | |
| # requires `pull-requests: read` on the workflow token; on public | |
| # repos the call is more permissive and `contents: read` alone | |
| # works (which is why the personal-website sister repo's identical | |
| # workflow passes without this scope). Without it, the action | |
| # fails at "Detect changed paths" with | |
| # `Resource not accessible by integration`. | |
| pull-requests: read | |
| # Cancel any in-flight run for the same ref the moment a new commit lands. | |
| # Same convention as OpenPost. | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| changes: | |
| name: Detect Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| app: ${{ steps.filter.outputs.app }} | |
| ci: ${{ steps.filter.outputs.ci }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Detect changed paths | |
| id: filter | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| app: | |
| - 'app/**' | |
| - 'src/**' | |
| - 'assets/**' | |
| - 'modules/**' | |
| - 'components.json' | |
| - 'eas.json' | |
| - 'app.json' | |
| - 'babel.config.js' | |
| - 'eslint.config.js' | |
| - 'metro.config.js' | |
| - 'global.css' | |
| - 'polyfills.ts' | |
| - 'tsconfig.json' | |
| - 'package.json' | |
| - 'bun.lock' | |
| - 'devenv.nix' | |
| - 'devenv.yaml' | |
| - 'devenv.lock' | |
| ci: | |
| - '.github/workflows/**' | |
| setup-nix-store: | |
| name: Setup Nix Store | |
| runs-on: ubuntu-latest | |
| needs: changes | |
| if: needs.changes.outputs.app == 'true' || needs.changes.outputs.ci == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v31 | |
| - name: Set up devenv cache | |
| uses: cachix/cachix-action@v16 | |
| with: | |
| name: devenv | |
| - name: Restore shared Nix store | |
| id: nix-cache-restore | |
| uses: nix-community/cache-nix-action/restore@v7 | |
| with: | |
| primary-key: nix-${{ runner.os }}-devenv-${{ hashFiles('devenv.nix', 'devenv.yaml', 'devenv.lock', 'bun.lock') }} | |
| restore-prefixes-first-match: | | |
| nix-${{ runner.os }}-devenv- | |
| - name: Install devenv | |
| shell: bash | |
| run: nix profile add nixpkgs#devenv | |
| - name: Warm devenv shell | |
| shell: bash | |
| run: devenv shell -- true | |
| - name: Save shared Nix store | |
| if: steps.nix-cache-restore.outputs.hit-primary-key != 'true' | |
| uses: nix-community/cache-nix-action/save@v7 | |
| with: | |
| primary-key: nix-${{ runner.os }}-devenv-${{ hashFiles('devenv.nix', 'devenv.yaml', 'devenv.lock', 'bun.lock') }} | |
| gc-max-store-size-linux: 3G | |
| checks: | |
| name: Format, typecheck, lint, and test | |
| runs-on: ubuntu-latest | |
| needs: [changes, setup-nix-store] | |
| if: needs.changes.outputs.app == 'true' || needs.changes.outputs.ci == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v31 | |
| - name: Set up devenv cache | |
| uses: cachix/cachix-action@v16 | |
| with: | |
| name: devenv | |
| - name: Restore shared Nix store | |
| uses: nix-community/cache-nix-action/restore@v7 | |
| with: | |
| primary-key: nix-${{ runner.os }}-devenv-${{ hashFiles('devenv.nix', 'devenv.yaml', 'devenv.lock', 'bun.lock') }} | |
| restore-prefixes-first-match: | | |
| nix-${{ runner.os }}-devenv- | |
| - name: Install devenv | |
| shell: bash | |
| run: nix profile add nixpkgs#devenv | |
| - name: Set up Bun cache | |
| if: needs.changes.outputs.app == 'true' || needs.changes.outputs.ci == 'true' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }} | |
| restore-keys: | | |
| bun-${{ runner.os }}- | |
| - name: Run relevant checks | |
| shell: devenv shell bash -- -e {0} | |
| env: | |
| APP_CHANGED: ${{ needs.changes.outputs.app }} | |
| CI_CHANGED: ${{ needs.changes.outputs.ci }} | |
| run: | | |
| # App/ci changes -> run everything; ci-only changes also run | |
| # the full suite so a workflow tweak never lands without the | |
| # checks actually being valid. | |
| if [[ "$APP_CHANGED" == "true" || "$CI_CHANGED" == "true" ]]; then | |
| format-check | |
| typecheck | |
| lint | |
| test | |
| fi |