Rust rewrite #2061
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: "Build & Test" | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [[self-hosted, linux, X64], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]] | |
runs-on: ${{ matrix.os }} | |
outputs: | |
bin: ${{ steps.build.outputs.bin }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v26 | |
with: | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
- uses: cachix/cachix-action@v14 | |
with: | |
name: devenv | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- id: build | |
run: | | |
bin=$(nix build --print-out-paths) | |
echo "bin=$bin" >> $GITHUB_OUTPUT | |
- name: Run tests | |
run: ./result/bin/devenv test | |
tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [[self-hosted, linux, X64], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v26 | |
with: | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
- uses: cachix/cachix-action@v14 | |
with: | |
name: devenv | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- run: | | |
nix-store -r ${{ needs.build.outputs.bin }} | |
PATH=${{ needs.build.outputs.bin }}/bin:$PATH ${{ needs.build.outputs.bin }}/bin/devenv-run-tests tests | |
pin: | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: ./.github/workflows/pin.yml | |
secrets: inherit | |
generate-examples: | |
runs-on: [self-hosted, linux, X64] | |
outputs: | |
examples: ${{ steps.set-examples.outputs.examples }} | |
steps: | |
- name: Checkout base repo | |
uses: actions/checkout@v4 | |
- id: set-examples | |
run: | | |
json=$(nix shell nixpkgs#tree -c tree -J -L 1 examples | nix shell nixpkgs#jq -c jq -c '[.[0].contents[] | .name]') | |
echo "examples=$json" >> $GITHUB_OUTPUT | |
examples: | |
name: ${{ matrix.example }} (${{ join(matrix.os) }}) | |
needs: [generate-examples, build] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]] | |
example: ${{ fromJSON(needs.generate-examples.outputs.examples) }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- run: sudo rm -rf /opt& | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v26 | |
with: | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
- uses: cachix/cachix-action@v14 | |
with: | |
name: devenv | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- run: | | |
nix-store -r ${{ needs.build.outputs.bin }} | |
PATH=${{ needs.build.outputs.bin }}/bin:$PATH ${{ needs.build.outputs.bin }}/bin/devenv-run-tests --only ${{ matrix.example }} examples | |
direnv: | |
name: direnv (${{ join(matrix.os) }}) | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, Linux, ARM64]] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v26 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
- uses: cachix/cachix-action@v14 | |
with: | |
name: devenv | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- run: | | |
mkdir -p ~/.config/direnv/ | |
cat > ~/.config/direnv/direnv.toml << 'EOF' | |
[global] | |
strict_env = true | |
EOF | |
devenv_dir=$PWD | |
export PATH=${{ needs.build.outputs.bin }}/bin:$PATH | |
nix-store -r ${{ needs.build.outputs.bin }} | |
pushd examples/simple | |
devenv inputs add devenv path:$devenv_dir?dir=src/modules | |
nix shell nixpkgs#direnv -c direnv allow . | |
nix shell nixpkgs#direnv -c direnv exec . true | |
popd | |
fish-zsh: | |
name: zsh/fish (${{ join(matrix.os) }}) | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v26 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
- uses: cachix/cachix-action@v14 | |
with: | |
name: devenv | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- run: nix-store -r ${{ needs.build.outputs.bin }} | |
- run: | | |
nix shell nixpkgs#zsh -c zsh -c "${{ needs.build.outputs.bin }}/bin/devenv version" | |
nix shell nixpkgs#fish -c fish -c "${{ needs.build.outputs.bin }}/bin/devenv version" |