From 6c39ebb7833853ac898d6d19fb9e0958c11fc51b Mon Sep 17 00:00:00 2001 From: Farbod Ahmadian Date: Tue, 5 Nov 2024 10:55:42 +0100 Subject: [PATCH 1/3] refactor: add cache to CI --- .github/workflows/test.yml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ff70e3f..08a62d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,14 +7,28 @@ on: - main jobs: - # Mac tests and Ubuntu tests are separated so that Ubuntu tests can - # run on both PRs and main; and Mac tests only on main branch. ubuntu_tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + # Add a separate step to adjust permissions + - name: Adjust Permissions on Nix Store + run: sudo mkdir /nix && sudo chown -R $USER:$USER /nix/ + + - name: Cache Nix Store + uses: actions/cache@v3 + with: + path: /nix/store + key: nix-store-${{ runner.os }}-${{ hashFiles('**/shell.nix') }} + restore-keys: | + nix-store-${{ runner.os }}- + + - name: Show caches packages + run: ls /nix/store + - uses: cachix/install-nix-action@v26 + - uses: cachix/cachix-action@v14 with: name: devenv @@ -23,7 +37,7 @@ jobs: run: nix profile install nixpkgs#devenv - name: Build the devenv shell and run any pre-commit hooks - run: devenv test + run: ls /nix/store && nix-store --verify --check-contents macos_tests: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} @@ -31,6 +45,14 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Cache Nix Store + uses: actions/cache@v3 + with: + path: /nix/store + key: nix-store-${{ runner.os }}-${{ hashFiles('**/shell.nix') }} + restore-keys: | + nix-store-${{ runner.os }}- + - name: Setup Docker (macOS) with Colima run: | brew install docker docker-compose colima From a7a0e5b6e4a79b7b23e608227da52ae528237eec Mon Sep 17 00:00:00 2001 From: Farbod Ahmadian Date: Wed, 6 Nov 2024 13:56:39 +0100 Subject: [PATCH 2/3] refactor: use Cachix --- .github/workflows/test.yml | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08a62d5..ef53778 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,35 +9,37 @@ on: jobs: ubuntu_tests: runs-on: ubuntu-latest + permissions: + actions: write + contents: read + id-token: write steps: - uses: actions/checkout@v4 # Add a separate step to adjust permissions - - name: Adjust Permissions on Nix Store - run: sudo mkdir /nix && sudo chown -R $USER:$USER /nix/ + # - name: Adjust Permissions on Nix Store + # run: sudo mkdir /nix && sudo chown -R $USER:$USER /nix/ - - name: Cache Nix Store - uses: actions/cache@v3 - with: - path: /nix/store - key: nix-store-${{ runner.os }}-${{ hashFiles('**/shell.nix') }} - restore-keys: | - nix-store-${{ runner.os }}- + # - name: Cache Nix Store + # uses: actions/cache@v3 + # with: + # path: /nix/store + # key: nix-store-${{ runner.os }}-${{ hashFiles('**/shell.nix') }} + # restore-keys: | + # nix-store-${{ runner.os }}- - - name: Show caches packages - run: ls /nix/store + # - name: Show caches packages + # run: ls /nix/store - uses: cachix/install-nix-action@v26 - - uses: cachix/cachix-action@v14 - with: - name: devenv + - uses: DeterminateSystems/magic-nix-cache-action@main - name: Install devenv.sh run: nix profile install nixpkgs#devenv - name: Build the devenv shell and run any pre-commit hooks - run: ls /nix/store && nix-store --verify --check-contents + run: devenv test macos_tests: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} From 53ff7ea426f7ae01b988aee44a9cbe3c3ca92f41 Mon Sep 17 00:00:00 2001 From: Farbod Ahmadian Date: Thu, 7 Nov 2024 09:19:18 +0100 Subject: [PATCH 3/3] refactor: use Cachix --- .github/workflows/test.yml | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ef53778..3be0821 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,21 +16,6 @@ jobs: steps: - uses: actions/checkout@v4 - # Add a separate step to adjust permissions - # - name: Adjust Permissions on Nix Store - # run: sudo mkdir /nix && sudo chown -R $USER:$USER /nix/ - - # - name: Cache Nix Store - # uses: actions/cache@v3 - # with: - # path: /nix/store - # key: nix-store-${{ runner.os }}-${{ hashFiles('**/shell.nix') }} - # restore-keys: | - # nix-store-${{ runner.os }}- - - # - name: Show caches packages - # run: ls /nix/store - - uses: cachix/install-nix-action@v26 - uses: DeterminateSystems/magic-nix-cache-action@main @@ -47,14 +32,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Cache Nix Store - uses: actions/cache@v3 - with: - path: /nix/store - key: nix-store-${{ runner.os }}-${{ hashFiles('**/shell.nix') }} - restore-keys: | - nix-store-${{ runner.os }}- - - name: Setup Docker (macOS) with Colima run: | brew install docker docker-compose colima @@ -66,9 +43,7 @@ jobs: curl -s --unix-socket $HOME/.colima/default/docker.sock http/_ping - uses: cachix/install-nix-action@v26 - - uses: cachix/cachix-action@v14 - with: - name: devenv + - uses: DeterminateSystems/magic-nix-cache-action@main - name: Install devenv.sh run: nix profile install nixpkgs#devenv