Skip to content

Commit

Permalink
ci: use Nix on CI
Browse files Browse the repository at this point in the history
Keep Docker as a sanity check
  • Loading branch information
hraban committed May 5, 2023
1 parent ff45096 commit 7a029f2
Showing 1 changed file with 33 additions and 43 deletions.
76 changes: 33 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,63 @@ defaults:

jobs:

build:
timeout-minutes: 10
name: "Build: compile source code and export HTML"
nix:
runs-on: ubuntu-latest
name: "Build using Nix"
steps:
- name: Checkout code
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Checkout
uses: actions/checkout@v2
- # This is very wasteful but caching docker images on GH actions is
# INSANELY DIFFICULT!!! Honestly they bring it on themselves, this is
# not an abstruse setup. But until I can cache docker images (let alone
# layers), without pollution between branches / PRs, and without
# 1873907182301273 lines of code, config and separate auths and external
# services, I’ll just stick to rebuilding the entire image every time.
name: Build the Docker image
run: docker-compose build
name: Install Nix
uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
-
name: Tangle code and export HTML
run: docker-compose run --rm build
run: "nix build .#dist"
-
name: Test
run: nix flake check
-
name: Create artifact bundle
run: tar cvf artifacts.tar test tomono index.html style.css
run:
(cd result/bin && tar cvf $OLDPWD/artifacts.tar tomono)
(cd result/doc && tar rvf $OLDPWD/artifacts.tar index.html style.css)
-
uses: actions/upload-artifact@v3
with:
name: bundle-${{github.sha}}
path: artifacts.tar

test:
docker:
timeout-minutes: 10
name: "Test"
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
needs: build
name: "Build using Docker"
runs-on: ubuntu-latest
steps:
-
name: Remove files before artifact download
run: rm -rf artifacts.tar
-
uses: actions/download-artifact@v3
with:
name: bundle-${{github.sha}}
-
name: Unpack artifacts
run: tar xvf artifacts.tar
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Set up git for CI
run: |
git config --global user.name CI
git config --global user.email c@i
git config --global init.defaultBranch master
git config --global core.autocrlf input
name: Checkout
uses: actions/checkout@v2
- # This is very wasteful but caching docker images on GH actions is
# INSANELY DIFFICULT!!! Honestly they bring it on themselves, this is
# not an abstruse setup. But until I can cache docker images (let alone
# layers), without pollution between branches / PRs, and without
# 1873907182301273 lines of code, config and separate auths and external
# services, I’ll just stick to rebuilding the entire image every time.
name: Build the Docker image
run: docker compose build
-
name: Run tests
run: ./test
name: Tangle code and export HTML
run: docker compose run --rm build

deploy_pages:
timeout-minutes: 10
if: ${{ github.ref_type == 'branch' && github.ref == 'refs/heads/master' }}
name: "Deploy the HTML to GitHub Pages"
runs-on: ubuntu-latest
needs: build
needs: nix
steps:
-
name: Checkout
Expand Down

0 comments on commit 7a029f2

Please sign in to comment.