diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8e19ca0..e67c857 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -38,7 +38,7 @@ jobs: - name: Install devbox uses: ./ with: - devbox-version: 0.5.5 + devbox-version: 0.5.13 project-path: 'testdata' disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}" @@ -60,10 +60,10 @@ jobs: - name: Install devbox uses: ./ with: - devbox-version: 0.5.5 + devbox-version: 0.5.13 refresh-cli: true project-path: 'testdata' - sha256-checksum: 'd5e623c032d38250346301040d51bcdca8e6db051c3688cc452e0dda5d95a070' + sha256-checksum: '481cc5d270a22843d7f7c34eac6cea4bbe9f2cdfbc72f0217ea3823ebabecc43' disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}" test-action-with-sha256-checksum-failure: @@ -75,7 +75,7 @@ jobs: uses: ./ continue-on-error: true with: - devbox-version: 0.5.5 + devbox-version: 0.5.13 refresh-cli: true sha256-checksum: 'bad-sha' project-path: 'testdata' @@ -91,9 +91,9 @@ jobs: - name: Install devbox uses: ./ with: - devbox-version: 0.5.5 + devbox-version: 0.5.13 enable-cache: true refresh-cli: true - sha256-checksum: '3c2ce11638e3ffcd55881ec20143c38feeb24069ccdb5edf82b343c168aaca32' + sha256-checksum: 'f5907e5782f6e1f5a7ca32c8ae2a0a81618549314bab237174a46fb216f43809' project-path: 'testdata' disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}" diff --git a/README.md b/README.md index 93ce48f..652c8af 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ jobs: ### Action Inputs | Input argument | description | default | -| ---------------- | ------------------------------------------------------------------------------------- | --------------------- | +| ------------------------ | ------------------------------------------------------------------------------------- | --------------------- | | project-path | Path to the folder that contains a valid `devbox.json` | repo's root directory | | enable-cache | Cache the entire Nix store in github based on your `devbox.json` | false | | refresh-cli | Specify whether the CLI should be redownloaded | false | @@ -51,7 +51,7 @@ Here's an example job with all inputs: project-path: 'path-to-folder' enable-cache: 'true' refresh-cli: 'false' - devbox-version: 0.5.11 + devbox-version: 0.5.13 disable-nix-access-token: 'false' - sha256-sum: b6f7e24839de004ef2cad312f05865f77a73b1e0b1757e0f4d39a5911adabd50 + sha256-sum: f5907e5782f6e1f5a7ca32c8ae2a0a81618549314bab237174a46fb216f43809 ``` diff --git a/action.yml b/action.yml index 933cd72..cd6db15 100644 --- a/action.yml +++ b/action.yml @@ -26,23 +26,6 @@ inputs: runs: using: "composite" steps: - - name: Workaround for permission issue - if: inputs.enable-cache == 'true' && runner.os != 'macOS' - shell: bash - run: sudo chmod u+s "$(command -v tar)" - - - name: Mount nix store cache - if: inputs.enable-cache == 'true' - uses: actions/cache@v3 - with: - path: | - ~/.nix-defexpr - ~/.nix-profile - /nix/store - /nix/var/nix - ~/.local/state/nix - key: ${{ runner.os }}-devbox-${{ hashFiles(format('{0}/devbox.lock', inputs.project-path)) }} - - name: Get devbox version shell: bash env: @@ -81,8 +64,6 @@ runs: export DEVBOX_USE_VERSION="${{ env.latest_version }}" curl -fsSL https://get.jetpack.io/devbox | FORCE=1 bash - devbox setup nix # temporary until 0.5.13 is released - version=$(devbox version) if [[ ! "$version" = "$DEVBOX_USE_VERSION" ]]; then echo "ERROR: mismatch devbox version downloaded. Expected $DEVBOX_USE_VERSION, got $version." @@ -110,6 +91,19 @@ runs: fi sudo mv "$DEVBOX_BINARY" /usr/local/bin/devbox + - name: Workaround nix store cache permission issue + if: inputs.enable-cache == 'true' + shell: bash + run: | + if [ "$RUNNER_OS" == "macOS" ]; then + sudo mv /usr/local/bin/gtar /usr/local/bin/gtar.orig + echo "#!/bin/sh" >> /usr/local/bin/gtar + echo 'exec sudo /usr/local/bin/gtar.orig "$@"' >> /usr/local/bin/gtar + sudo chmod +x /usr/local/bin/gtar + else + sudo chmod u+s "$(command -v tar)" + fi + - name: Configure nix access-tokens if: inputs.disable-nix-access-token == 'false' shell: bash @@ -117,9 +111,26 @@ runs: mkdir -p ~/.config/nix echo "access-tokens = github.com=${{ github.token }}" >> ~/.config/nix/nix.conf - - name: Install nix and devbox packages + - name: Install nix + uses: DeterminateSystems/nix-installer-action@v4 + with: + logger: pretty + extra-conf: experimental-features = ca-derivations fetch-closure + + - name: Mount nix store cache + if: inputs.enable-cache == 'true' + uses: actions/cache@v3 + with: + path: | + ~/.cache + ~/.local/state/nix + ~/.nix-defexpr + ~/.nix-profile + /nix/store + /nix/var/nix + key: ${{ runner.os }}-devbox-${{ hashFiles(format('{0}/devbox.lock', inputs.project-path)) }} + + - name: Install devbox packages shell: bash run: | - NIX_INSTALLER_NO_CHANNEL_ADD=1 - NIX_BUILD_SHELL=/bin/bash devbox run --config=${{ inputs.project-path }} -- echo "Packages installed!" diff --git a/testdata/devbox.lock b/testdata/devbox.lock new file mode 100644 index 0000000..75da611 --- /dev/null +++ b/testdata/devbox.lock @@ -0,0 +1,11 @@ +{ + "lockfile_version": "1", + "packages": { + "go@latest": { + "last_modified": "2023-09-17T10:54:49Z", + "resolved": "github:NixOS/nixpkgs/5148520bfab61f99fd25fb9ff7bfbb50dad3c9db#go_1_21", + "source": "devbox-search", + "version": "1.21.1" + } + } +}