ci: run tests on mac & ubuntu without Nix #110
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/CD" | |
"on": | |
pull_request: {} | |
push: | |
branches: ["**"] | |
tags: ["**"] | |
env: | |
DOCKER_BUILDKIT: 1 | |
defaults: | |
run: | |
# For the windows phase | |
shell: bash | |
jobs: | |
build: | |
timeout-minutes: 10 | |
name: "Build and Test" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- | |
name: Install Nix | |
uses: cachix/install-nix-action@v20 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
- | |
name: Tangle code and export HTML | |
run: "nix build .#dist" | |
- | |
name: "Test: integration test" | |
run: nix flake check | |
- | |
name: "Test: vendored script equals build" | |
run: diff -u ./tomono result/bin/tomono | |
- | |
name: Create artifact bundle | |
run: | | |
(cd result/bin && tar cvf $OLDPWD/executables.tar tomono test) | |
(cd result/doc && tar rvf $OLDPWD/website.tar index.html style.css) | |
- | |
if: ${{ github.ref_type == 'branch' && github.ref == 'refs/heads/master' }} | |
uses: actions/upload-artifact@v3 | |
name: "Upload website artifacts" | |
with: | |
name: website-${{github.sha}} | |
path: website.tar | |
- | |
uses: actions/upload-artifact@v3 | |
name: "Upload binary artifacts" | |
with: | |
name: executables-${{github.sha}} | |
path: binaries.tar | |
test-nonix: | |
timeout-minutes: 10 | |
name: "Test stand-alone binary without Nix" | |
needs: build | |
strategy: | |
matrix: | |
config: | |
- ubuntu-latest | |
- macos-latest | |
runs-on: ${{ matrix.config }} | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: executables-${{github.sha}} | |
- name: Unpack artifacts | |
run: | | |
tar xvf artifacts.tar index.html style.css | |
rm -f artifacts.tar | |
- name: Run tests | |
run: | | |
./test | |
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 | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: gh-pages | |
- name: Remove files before artifact download | |
run: rm -f artifacts.tar | |
- | |
uses: actions/download-artifact@v3 | |
with: | |
name: bundle-${{github.sha}} | |
- name: Unpack artifacts | |
run: | | |
tar xvf artifacts.tar index.html style.css | |
rm -f artifacts.tar | |
- | |
name: configure git | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "<>" | |
- | |
name: "Commit the HTML to gh-pages branch" | |
run: | | |
git add -A | |
git commit -m "Update gh-pages from ${{github.ref}} @ ${{github.sha}}" | |
git push origin gh-pages |