2021-12-21 22:26:52 +02:00
|
|
|
name: "CI"
|
2021-10-29 15:38:55 +03:00
|
|
|
|
2020-03-13 12:57:58 +02:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
2021-10-29 15:38:55 +03:00
|
|
|
|
2020-03-13 12:57:58 +02:00
|
|
|
jobs:
|
2021-10-29 15:38:55 +03:00
|
|
|
|
2020-03-13 12:57:58 +02:00
|
|
|
tests:
|
2021-09-02 02:08:38 +03:00
|
|
|
needs: [check_cachix]
|
2020-03-13 12:57:58 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2020-05-15 11:06:14 +03:00
|
|
|
os: [ubuntu-latest, macos-latest]
|
2020-03-13 12:57:58 +02:00
|
|
|
runs-on: ${{ matrix.os }}
|
2021-10-29 15:38:55 +03:00
|
|
|
timeout-minutes: 60
|
2020-03-13 12:57:58 +02:00
|
|
|
steps:
|
2022-04-13 15:10:29 +03:00
|
|
|
- uses: actions/checkout@v3
|
2020-03-13 18:25:47 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-04-12 01:01:20 +03:00
|
|
|
- uses: cachix/install-nix-action@v17
|
2021-02-26 00:12:51 +02:00
|
|
|
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
|
2021-04-12 08:21:11 +03:00
|
|
|
- uses: cachix/cachix-action@v10
|
2021-09-02 02:08:38 +03:00
|
|
|
if: needs.check_cachix.outputs.secret == 'true'
|
2021-02-15 12:20:54 +02:00
|
|
|
with:
|
|
|
|
name: '${{ env.CACHIX_NAME }}'
|
|
|
|
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
2021-02-26 00:12:51 +02:00
|
|
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
2022-01-26 15:31:23 +02:00
|
|
|
- run: nix --experimental-features 'nix-command flakes' flake check -L
|
2021-10-29 15:38:55 +03:00
|
|
|
|
2021-02-26 00:12:51 +02:00
|
|
|
check_cachix:
|
|
|
|
name: Cachix secret present for installer tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
secret: ${{ steps.secret.outputs.secret }}
|
|
|
|
steps:
|
|
|
|
- name: Check for Cachix secret
|
|
|
|
id: secret
|
|
|
|
env:
|
|
|
|
_CACHIX_SECRETS: ${{ secrets.CACHIX_SIGNING_KEY }}${{ secrets.CACHIX_AUTH_TOKEN }}
|
|
|
|
run: echo "::set-output name=secret::${{ env._CACHIX_SECRETS != '' }}"
|
2021-10-29 15:38:55 +03:00
|
|
|
|
2021-02-15 12:20:54 +02:00
|
|
|
installer:
|
2021-02-26 00:12:51 +02:00
|
|
|
needs: [tests, check_cachix]
|
|
|
|
if: github.event_name == 'push' && needs.check_cachix.outputs.secret == 'true'
|
2021-02-15 12:20:54 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
installerURL: ${{ steps.prepare-installer.outputs.installerURL }}
|
|
|
|
steps:
|
2022-04-13 15:10:29 +03:00
|
|
|
- uses: actions/checkout@v3
|
2021-02-15 12:20:54 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2021-02-26 00:12:51 +02:00
|
|
|
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
|
2022-04-12 01:01:20 +03:00
|
|
|
- uses: cachix/install-nix-action@v17
|
2021-04-12 08:21:11 +03:00
|
|
|
- uses: cachix/cachix-action@v10
|
2021-02-15 12:20:54 +02:00
|
|
|
with:
|
|
|
|
name: '${{ env.CACHIX_NAME }}'
|
|
|
|
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
2021-02-26 00:12:51 +02:00
|
|
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
2021-02-15 12:20:54 +02:00
|
|
|
- id: prepare-installer
|
|
|
|
run: scripts/prepare-installer-for-github-actions
|
2021-10-29 15:38:55 +03:00
|
|
|
|
2021-02-15 12:20:54 +02:00
|
|
|
installer_test:
|
2021-02-26 00:12:51 +02:00
|
|
|
needs: [installer, check_cachix]
|
|
|
|
if: github.event_name == 'push' && needs.check_cachix.outputs.secret == 'true'
|
2021-02-15 12:20:54 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest, macos-latest]
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2022-04-13 15:10:29 +03:00
|
|
|
- uses: actions/checkout@v3
|
2021-02-26 00:12:51 +02:00
|
|
|
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
|
2022-04-12 01:01:20 +03:00
|
|
|
- uses: cachix/install-nix-action@v17
|
2021-02-15 12:20:54 +02:00
|
|
|
with:
|
|
|
|
install_url: '${{needs.installer.outputs.installerURL}}'
|
2021-02-26 00:12:51 +02:00
|
|
|
install_options: "--tarball-url-prefix https://${{ env.CACHIX_NAME }}.cachix.org/serve"
|
2021-02-15 12:20:54 +02:00
|
|
|
- run: nix-instantiate -E 'builtins.currentTime' --eval
|
2021-12-21 23:42:47 +02:00
|
|
|
|
|
|
|
docker_push_image:
|
|
|
|
needs: [check_cachix, tests]
|
|
|
|
if: >-
|
|
|
|
github.event_name == 'push' &&
|
|
|
|
github.ref_name == 'master' &&
|
|
|
|
needs.check_cachix.outputs.secret == 'true'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-04-13 15:10:29 +03:00
|
|
|
- uses: actions/checkout@v3
|
2021-12-21 23:42:47 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-04-12 01:01:20 +03:00
|
|
|
- uses: cachix/install-nix-action@v17
|
2021-12-21 23:42:47 +02:00
|
|
|
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
|
2022-06-10 13:09:09 +03:00
|
|
|
- run: echo NIX_VERSION="$(nix --experimental-features 'nix-command flakes' eval .\#default.version | tr -d \")" >> $GITHUB_ENV
|
2021-12-21 23:42:47 +02:00
|
|
|
- uses: cachix/cachix-action@v10
|
|
|
|
if: needs.check_cachix.outputs.secret == 'true'
|
|
|
|
with:
|
|
|
|
name: '${{ env.CACHIX_NAME }}'
|
|
|
|
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
|
|
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
2022-01-26 15:31:23 +02:00
|
|
|
- run: nix --experimental-features 'nix-command flakes' build .#dockerImage -L
|
2021-12-21 23:42:47 +02:00
|
|
|
- run: docker load -i ./result/image.tar.gz
|
|
|
|
- run: docker tag nix:$NIX_VERSION nixos/nix:$NIX_VERSION
|
2022-01-21 15:40:34 +02:00
|
|
|
- run: docker tag nix:$NIX_VERSION nixos/nix:master
|
2021-12-21 23:42:47 +02:00
|
|
|
- name: Login to Docker Hub
|
2022-05-10 01:01:15 +03:00
|
|
|
uses: docker/login-action@v2
|
2021-12-21 23:42:47 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- run: docker push nixos/nix:$NIX_VERSION
|
2022-01-21 15:40:34 +02:00
|
|
|
- run: docker push nixos/nix:master
|