-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from nix-community/reusable-actions
ci: split out reusable actions
- Loading branch information
Showing
9 changed files
with
240 additions
and
142 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
inputs: | ||
expression: | ||
description: 'Nix expression to build' | ||
required: true | ||
|
||
outputs: | ||
derivation: | ||
description: 'Path to the built derivation' | ||
value: ${{ steps.build.outputs.derivation }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install Nix βοΈ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Build ${{ inputs.expression }} π οΈ | ||
id: build | ||
shell: bash | ||
run: | | ||
JSON=$(mktemp) | ||
(nix build -L ${{ inputs.expression }} --no-link --json >$JSON) |& sed -uE 's/^(trace: +)?warning:(\s+|$)/::warning::/;s/^(trace: +)?error:(\s+|$)/::error::/;s/^trace:(\s+|$)/::notice::trace: /' | ||
DRV=$(jq -r .[0].outputs.out <$JSON) | ||
echo "derivation=$DRV" >> $GITHUB_OUTPUT | ||
echo "- Built \`$DRV\`" >> $GITHUB_STEP_SUMMARY | ||
echo " - $(nix show-derivation -r $DRV | jq 'keys[]' | wc -l) derivations in closure" >> $GITHUB_STEP_SUMMARY | ||
echo " - $(nix path-info -S --json $DRV | jq -r '.[0].closureSize' | xargs numfmt --to=iec-i --suffix=B --format='%.3f') total size" >> $GITHUB_STEP_SUMMARY |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
inputs: | ||
config: | ||
description: 'System configuration to build' | ||
required: true | ||
filename: | ||
description: 'Filename to save the image as' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Build tarball builder π οΈ | ||
id: buildBuilder | ||
uses: ./.github/actions/build-nix-expression | ||
with: | ||
expression: '.#nixosConfigurations.${{ inputs.config }}.config.system.build.tarballBuilder' | ||
|
||
- name: Build tarball π¦ | ||
shell: bash | ||
run: sudo ${{ steps.buildBuilder.outputs.derivation }}/bin/nixos-wsl-tarball-builder ${{ inputs.filename }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check for nix β | ||
id: check-nix | ||
shell: bash | ||
run: | | ||
if command -v nix &> /dev/null | ||
then | ||
echo "nix-found=true" | tee -a $GITHUB_OUTPUT | ||
else | ||
echo "nix-found=false" | tee -a $GITHUB_OUTPUT | ||
fi | ||
- name: Install Nix βοΈ | ||
if: ${{ steps.check-nix.outputs.nix-found != 'true' }} | ||
uses: cachix/install-nix-action@v22 | ||
with: | ||
github_access_token: ${{ github.token }} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "Push" | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: {} | ||
|
||
jobs: | ||
build: | ||
name: Build Tarballs π οΈ | ||
uses: ./.github/workflows/run_build.yml | ||
|
||
checks: | ||
name: Flake Checks π | ||
uses: ./.github/workflows/run_checks.yml | ||
|
||
tests: | ||
name: Tests π§ͺ | ||
uses: ./.github/workflows/run_tests.yml | ||
needs: | ||
- build |
13 changes: 7 additions & 6 deletions
13
.github/workflows/release.yml β .github/workflows/on_release.yml
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build Tarballs | ||
|
||
on: | ||
workflow_call: {} | ||
|
||
jobs: | ||
build: | ||
name: Build π οΈ | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
config: | ||
- modern | ||
- legacy | ||
- test | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Nix βοΈ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Generate Version π·οΈ | ||
id: version | ||
run: | | ||
TAG_COUNT=$(git rev-list --tags --no-walk --count) # Count all tags | ||
COMMIT_COUNT=$(git rev-list --use-bitmap-index --count $(git rev-list --tags --no-walk --max-count=1)..HEAD) # Count all commits since the last tag | ||
NIXOS_VERSION=$(nix-instantiate --eval -E '(import ./.).inputs.nixpkgs.lib.version' | sed -E 's/"(.+\...).*"/\1/') # Get NixOS version from nixpkgs | ||
NIXOS_VERSION_MS=$(echo $NIXOS_VERSION | sed -E 's/\.0*(.+)/\.\1/') # Remove the leading 0 from the minor version (if it exists) | ||
NIXOS_WSL_VERSION=${NIXOS_VERSION_MS}.${TAG_COUNT}.${COMMIT_COUNT} # Compose the NixOS-WSL version number | ||
echo "version=$NIXOS_WSL_VERSION" >> $GITHUB_OUTPUT | ||
echo $NIXOS_WSL_VERSION > ./VERSION | ||
echo $(git rev-parse HEAD) >> ./VERSION | ||
- name: Build Tarball π οΈ | ||
uses: ./.github/actions/build-wsl-tarball | ||
with: | ||
config: ${{ matrix.config }} | ||
filename: nixos-wsl.tar.gz | ||
|
||
- name: Upload Tarball π€ | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: tarball-${{ matrix.config }} | ||
path: nixos-wsl.tar.gz |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Flake Checks | ||
|
||
on: | ||
workflow_call: {} | ||
|
||
jobs: | ||
prepare: | ||
name: Find Checks π | ||
runs-on: ubuntu-latest | ||
outputs: | ||
checks: ${{ steps.checks.outputs.checks }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Nix βοΈ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Find Checks π | ||
id: checks | ||
run: | | ||
nix-instantiate --json --eval --strict -E 'with builtins; attrNames (getFlake (toString ./.)).checks.${currentSystem}' | perl -pe 's|(.*)|checks=\1|' >>$GITHUB_OUTPUT | ||
checks: | ||
name: Check π | ||
needs: | ||
- prepare | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
check: ${{ fromJSON(needs.prepare.outputs.checks) }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Nix βοΈ | ||
uses: ./.github/actions/install-nix | ||
|
||
- name: Run Check π | ||
run: | | ||
nix build -L --impure --expr "with builtins; (getFlake (toString ./.)).checks.\${currentSystem}.${{ matrix.check }}" |
Oops, something went wrong.