Merge pull request #295 from nix-community/prep-release #758
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' | |
on: | |
push: | |
branches: [main] | |
pull_request: {} | |
workflow_call: {} | |
jobs: | |
prepare: | |
name: Prepare π | |
runs-on: ubuntu-latest | |
outputs: | |
tests: ${{ steps.tests.outputs.tests }} | |
checks: ${{ steps.checks.outputs.checks }} | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install nix βοΈ | |
uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23 | |
with: | |
extra_nix_config: 'access-tokens = github.com=${{ github.token }}' | |
- name: Find tests π | |
id: tests | |
run: | | |
find tests -name '*.Tests.ps1' -print0 | perl -pe 's|(.*?)\x0|"\1",|g;s|,$||;s|(.*)|tests=[\1]|' >> $GITHUB_OUTPUT | |
- 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 | |
- 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 | |
build: | |
name: Build π οΈ | |
needs: | |
- prepare | |
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: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23 | |
with: | |
extra_nix_config: 'access-tokens = github.com=${{ github.token }}' | |
- name: Set version π·οΈ | |
run: | | |
echo ${{ needs.prepare.outputs.version }} > ./VERSION | |
echo $(git rev-parse HEAD) >> ./VERSION | |
- name: Build tarballs π οΈ | |
# We can't just nix run here because nix is not on root's PATH in the container | |
run: | | |
nix build .#nixosConfigurations.${{ matrix.config }}.config.system.build.tarballBuilder | |
sudo ./result/bin/nixos-wsl-tarball-builder nixos-wsl.tar.gz | |
- name: Upload tarball π€ | |
uses: actions/upload-artifact@v3 | |
with: | |
name: tarball-${{ matrix.config }} | |
path: nixos-wsl.tar.gz | |
checks: | |
name: Flake 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: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23 | |
with: | |
extra_nix_config: 'access-tokens = github.com=${{ github.token }}' | |
- name: Run check π | |
run: | | |
nix build -L --impure --expr "with builtins; (getFlake (toString ./.)).checks.\${currentSystem}.${{ matrix.check }}" | |
tests: | |
name: Test π§ͺ | |
needs: | |
- prepare | |
- build | |
strategy: | |
fail-fast: false | |
matrix: | |
test: ${{ fromJSON(needs.prepare.outputs.tests) }} | |
os: | |
- ubuntu-20.04 | |
# - windows-latest # doesn't work due to lack of nested virtualization on the runners, hopefully this will work one day | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download tarball π₯ | |
uses: actions/download-artifact@v3 | |
with: | |
name: tarball-test | |
- name: Execute test π§ͺ | |
shell: pwsh | |
run: | | |
Invoke-Pester -Output Detailed ${{ matrix.test }} |