diff --git a/.github/actions/setup-cargo-codspeed/action.yml b/.github/actions/setup-cargo-codspeed/action.yml new file mode 100644 index 00000000..31254d4f --- /dev/null +++ b/.github/actions/setup-cargo-codspeed/action.yml @@ -0,0 +1,27 @@ +name: 'Setup cargo-codspeed' +description: 'Install cargo-codspeed using cache if possible' +inputs: + version: + description: "Version to install" + required: true + default: '1.1.0' + +outputs: + cache-hit: + description: "Was the cache hit" + value: ${{ steps.cache.outputs.cache-hit }} + +runs: + using: "composite" + steps: + - name: Cache cargo-codspeed + id: cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/cargo-codspeed + key: cargo-codspeed-${{ inputs.version }} + - name: Install cargo-codspeed specific version + if: steps.cache.outputs.cache-hit != 'true' + run: cargo install cargo-codspeed --version ${{ inputs.version }} + shell: bash diff --git a/.github/workflows/check-action.yml b/.github/workflows/check-action.yml new file mode 100644 index 00000000..3054c483 --- /dev/null +++ b/.github/workflows/check-action.yml @@ -0,0 +1,38 @@ +name: Check setup-cargo-codspeed action +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.ref }}-check-action + cancel-in-progress: true + +jobs: + setup-cargo-codspeed-action-cache-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - uses: ./.github/actions/setup-cargo-codspeed + + test-setup-cargo-codspeed-action-cache-hit: + needs: setup-cargo-codspeed-action-cache-build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - uses: ./.github/actions/setup-cargo-codspeed + id: setup-cargo-codspeed-again + - name: Check that the second install hit the cache + run: | + echo "Cache hit: ${{ steps.setup-cargo-codspeed-again.outputs.cache-hit }}" + if [ "${{ steps.setup-cargo-codspeed-again.outputs.cache-hit }}" != "true" ]; then + echo "Cache was not hit" + exit 1 + fi