diff --git a/.github/actions/nix_installer_and_cache/action.yml b/.github/actions/nix_installer_and_cache/action.yml index a7da03f61b0..055ee5bd92f 100644 --- a/.github/actions/nix_installer_and_cache/action.yml +++ b/.github/actions/nix_installer_and_cache/action.yml @@ -1,24 +1,32 @@ name: Nix Installer description: Nix Installer -outputs: - cache-hit: - description: "Indicate if cache is hit" - value: ${{ steps.nix-cache.outputs.cache-hit }} runs: using: composite steps: - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@3ebd1aebb47f95493b62de6eec0cac3cd74e50a9 + - name: Set Permission + run: | + # Create with liberal rights, otherwise cache action will complain + # about permission errors. + sudo mkdir -p /nix/store + sudo chmod -R 777 /nix - - name: Cache Nix Store + - name: Cache nix env take N+1 uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 - id: nix-cache with: - path: /tmp/nixcache - key: cache-nix-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('**/flake.lock') }} + path: | + # See https://github.com/actions/cache/pull/726 + /nix/store/** + # Missing something? + /nix/var/nix/*/* + /nix/var/nix/db/* + /nix/var/nix/db/*/** + !/nix/var/nix/daemon-socket/socket + !/nix/var/nix/userpool/* + !/nix/var/nix/gc.lock + !/nix/var/nix/db/big-lock + !/nix/var/nix/db/reserved + key: cache-nix-${{ hashFiles('**/flake.lock') }} - - name: Restore Nix Cache - shell: bash - if: steps.nix-cache.outputs.cache-hit == 'true' - run: nix copy --from /tmp/nixcache + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@3ebd1aebb47f95493b62de6eec0cac3cd74e50a9 diff --git a/.github/actions/upload_nix_store/action.yml b/.github/actions/upload_nix_store/action.yml deleted file mode 100644 index 7a207628242..00000000000 --- a/.github/actions/upload_nix_store/action.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Nix Store Upload -description: Nix Store Upload -inputs: - flake_nix_path: - description: Flake Nix Path - required: true - -runs: - using: composite - steps: - - name: Cache Nix store - shell: bash - run: nix copy --to /tmp/nixcache ${{ inputs.flake_nix_path }} diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 1788a2d6b9b..e5cc476f0ae 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -60,11 +60,8 @@ jobs: with: ref: ${{ github.event.inputs.commit_sha }} - uses: ./.github/actions/nix_installer_and_cache - id: nix-installer - uses: ./.github/actions/elixir_cache - run: make test working-directory: implementations/elixir - run: make lint working-directory: implementations/elixir - - uses: ./.github/actions/upload_nix_store - if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }} diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index e40943cd251..dca8c1b41a8 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -45,7 +45,7 @@ jobs: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: ${{ github.event.inputs.commit_sha }} - - uses: ./.github/actions/nix_installer + - uses: ./.github/actions/nix_installer_and_cache - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 - uses: ./.github/actions/elixir_cache - run: make diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d1e6cca0269..e0fe3a210c1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -72,7 +72,6 @@ jobs: - name: Install Nix uses: ./.github/actions/nix_installer_and_cache - id: nix-installer - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 with: @@ -80,12 +79,6 @@ jobs: - name: Run lint ${{ matrix.lint_projects }} run: make -f implementations/rust/Makefile lint_${{ matrix.lint_projects }} - - - name: Upload Nix Store - uses: ./.github/actions/upload_nix_store - with: - flake_nix_path: ./tools/nix - if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }} build: @@ -115,7 +108,6 @@ jobs: - name: Install Nix uses: ./.github/actions/nix_installer_and_cache - id: nix-installer - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 with: @@ -124,11 +116,6 @@ jobs: - name: Run build ${{ matrix.build_projects }} run: make -f implementations/rust/Makefile ${{ matrix.make_name }} - - uses: ./.github/actions/upload_nix_store - with: - flake_nix_path: ./tools/nix - if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }} - test: name: Rust - test${{ matrix.test_projects != 'stable' && format('_{0}', matrix.test_projects) || '' }} @@ -154,7 +141,6 @@ jobs: - name: Install Nix uses: ./.github/actions/nix_installer_and_cache - id: nix-installer - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 with: @@ -163,11 +149,6 @@ jobs: - name: Run test on ${{ matrix.test_projects }} run: make -f implementations/rust/Makefile test - - uses: ./.github/actions/upload_nix_store - with: - flake_nix_path: ./tools/nix - if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }} - check: name: Rust - check_${{ matrix.check_projects }} @@ -195,7 +176,6 @@ jobs: - name: Install Nix uses: ./.github/actions/nix_installer_and_cache - id: nix-installer - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 with: @@ -204,12 +184,6 @@ jobs: - name: Run check on ${{ matrix.check_projects }} run: | make -f implementations/rust/Makefile check${{ matrix.check_projects != 'nightly' && format('_{0}', matrix.check_projects) || '' }} - echo "kkddkk ${{ steps.nix-installer.outputs.cache-hit }}" - - - uses: ./.github/actions/upload_nix_store - with: - flake_nix_path: ./tools/nix - if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }} test_ockam_command: @@ -243,7 +217,6 @@ jobs: - name: Install Nix uses: ./ockam_bats/.github/actions/nix_installer_and_cache - id: nix-installer - name: Build Binary working-directory: ockam_cli @@ -269,11 +242,6 @@ jobs: OCKAM_DISABLE_UPGRADE_CHECK: 1 BATS_TEST_RETRIES: 2 - - uses: ./ockam_bats/.github/actions/upload_nix_store - with: - flake_nix_path: ./tools/nix - if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }} - ockam_command_cross_build: name: Rust - ockam_command_cross_build strategy: @@ -344,7 +312,6 @@ jobs: - name: Install Nix uses: ./ockam_library/.github/actions/nix_installer_and_cache - id: nix-installer - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 with: @@ -359,11 +326,6 @@ jobs: shell: nix develop ./tools/nix#rust --keep CI --ignore-environment --command bash {0} run: cargo test -p hello_ockam - - uses: ./ockam_library/.github/actions/upload_nix_store - with: - flake_nix_path: ./tools/nix - if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }} - lint_docs_ockam_io_rust_examples: name: Rust - lint_docs_ockam_io_rust_examples runs-on: ubuntu-22.04 @@ -383,7 +345,6 @@ jobs: - name: Install Nix uses: ./ockam/.github/actions/nix_installer_and_cache - id: nix-installer - name: Build Example Blocks working-directory: ockam @@ -393,9 +354,4 @@ jobs: - name: Check Rust Documentation run: | CHECK_MD_DIR="ockam-documentation/reference/libraries/rust" CHECK_MD_DIR_RUST_EXAMPLE="ockam/examples/rust/get_started" OCKAM_HOME="ockam" ockam/tools/docs/check_documentation.sh - - - uses: ./ockam/.github/actions/upload_nix_store - with: - flake_nix_path: ./tools/nix - if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }} \ No newline at end of file diff --git a/.github/workflows/shell.yml b/.github/workflows/shell.yml index 5f6c7dd3ab4..85c84a42638 100644 --- a/.github/workflows/shell.yml +++ b/.github/workflows/shell.yml @@ -54,7 +54,7 @@ jobs: ref: ${{ github.event.inputs.commit_sha }} - name: Install Nix - uses: ./.github/actions/nix_installer + uses: ./.github/actions/nix_installer_and_cache - name: Run Shfmt Check run: nix run ./tools/nix#shfmt-all