Lets see how well this works.
This commit is contained in:
parent
4291f26f4e
commit
bd10e5685c
1 changed files with 64 additions and 22 deletions
|
@ -1,12 +1,18 @@
|
|||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
|
||||
name: "Build"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: ["main"]
|
||||
paths: [".forgejo/workflows/build.yaml"]
|
||||
# schedule every night
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- ".forgejo/workflows/build.yaml"
|
||||
- "flake.lock"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
nix-build:
|
||||
if: github.event.pull_request.draft == false
|
||||
|
@ -20,6 +26,8 @@ jobs:
|
|||
os: native-x86_64
|
||||
- system: gandalf
|
||||
os: native-x86_64
|
||||
- system: telperion
|
||||
os: native-x86_64
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
PATH: ${{ format('{0}:{1}', '/run/current-system/sw/bin', env.PATH) }}
|
||||
|
@ -28,31 +36,65 @@ jobs:
|
|||
uses: https://github.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: https://github.com/cachix/cachix-action@v15
|
||||
- name: Set up Cachix
|
||||
uses: https://github.com/cachix/cachix-action@v15
|
||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||
with:
|
||||
name: hsndev
|
||||
# If you chose API tokens for write access OR if you have a private cache
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
# env:
|
||||
# USER: 'root'
|
||||
|
||||
- name: Garbage collect build dependencies
|
||||
run: nix-collect-garbage
|
||||
|
||||
- name: Build previous ${{ matrix.system }} system
|
||||
shell: bash
|
||||
run: |
|
||||
nix build git+https://git.hsn.dev/jahanson/mochi#top.${{ matrix.system }} \
|
||||
-v --log-format raw --profile ./profile
|
||||
- name: Build new ${{ matrix.system }} system
|
||||
shell: bash
|
||||
run: |
|
||||
set -o pipefail
|
||||
nix build \
|
||||
".#top.${{ matrix.system }}" \
|
||||
--profile ./profile \
|
||||
--fallback \
|
||||
-v \
|
||||
--log-format raw \
|
||||
> >(tee stdout.log) 2> >(tee /tmp/nix-build-err.log >&2)
|
||||
- name: Push to Cachix
|
||||
if: success()
|
||||
env:
|
||||
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||
run: nix build ".#top.${{ matrix.system }}" --json | jq -r .[].drvPath | cachix push hsndev
|
||||
nix build ".#top.${{ matrix.system }}" --profile ./profile --fallback -v \
|
||||
> >(tee stdout.log) 2> >(tee /tmp/nix-build-err.log >&2)
|
||||
- name: Check for build failure
|
||||
if: failure()
|
||||
run: |
|
||||
drv=$(grep "For full logs, run" /tmp/nix-build-err.log | grep -oE "/nix/store/.*.drv")
|
||||
if [ -n $drv ]; then
|
||||
nix log $drv
|
||||
echo $drv
|
||||
fi
|
||||
exit 1
|
||||
- name: Diff profile
|
||||
id: diff
|
||||
run: |
|
||||
nix profile diff-closures --profile ./profile
|
||||
delimiter="$(openssl rand -hex 16)"
|
||||
echo "diff<<${delimiter}" >> "${GITHUB_OUTPUT}"
|
||||
nix profile diff-closures --profile ./profile | perl -pe 's/\e\[[0-9;]*m(?:\e\[K)?//g' >> "${GITHUB_OUTPUT}"
|
||||
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
|
||||
- name: Comment report in pr
|
||||
uses: https://github.com/marocchino/sticky-pull-request-comment@v2
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
header: ".#top.${{ matrix.system }}"
|
||||
message: |
|
||||
### Report for `${{ matrix.system }}`
|
||||
|
||||
<summary> Version changes </summary> <br>
|
||||
<pre> ${{ steps.diff.outputs.diff }} </pre>
|
||||
# - name: Push to Cachix
|
||||
# if: success()
|
||||
# env:
|
||||
# CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||
# run: nix build ".#top.${{ matrix.system }}" --json | jq -r .[].drvPath | cachix push hsndev
|
||||
nix-build-success:
|
||||
if: ${{ always() }}
|
||||
needs:
|
||||
- nix-build
|
||||
name: Nix Build Successful
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
|
||||
name: Check matrix status
|
||||
run: exit 1
|
||||
|
|
Loading…
Reference in a new issue