Skip to content

Commit

Permalink
Attempt to speed up completion generation in CI
Browse files Browse the repository at this point in the history
By only generating it once for unix and once for windows and passing it
through outputs.
  • Loading branch information
tmccombs committed Dec 2, 2022
1 parent 3e2eaae commit e3d7f52
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,38 @@ jobs:
- name: Run tests
run: cargo test --locked

completions:
name: Generate shell completions
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
# Completions are different depending on the OS
job:
- { name: unix, os: ubuntu-20.04 }
- { name: windows, os: windows-2019 }
outputs:
unix: ${{ steps.archive.outputs.unix }}
windows: ${{ steps.archive.outputs.windows }}
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Install rsut toolchain
run: |
rustup set profile minimal
rustup toolchain install stable
rustup default stable
- name: Generate completions
# Use dev profile so it builds faster
run: make completions PROFILE=dev
- id: archive
name: Save completions
run: 'echo "${{ matrix.job.name }}=$(tar cz autocomplete | base64 -w0)" >> $GITHUB_OUTPUT'

build:
name: ${{ matrix.job.os }} (${{ matrix.job.target }})
runs-on: ${{ matrix.job.os }}
needs: completions
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -179,10 +208,17 @@ jobs:
- name: Run tests
run: ${{ env.CARGO_CMD }} test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}

- name: Generate completions
id: completions
- name: Extract pre-generated completions
id: unix-completions
if: "!startsWith(matrix.job.os, 'windows')"
shell: bash
run: 'base64 -d | tar xz <<<"${{ needs.completions.outputs.unix }}"'

- name: Extract pre-generated completions
id: windows-completions
if: startsWith(matrix.job.os, 'windows')
shell: bash
run: make completions
run: 'base64 -d | tar xz <<<"${{ needs.completions.outputs.windows }}"'

- name: Create tarball
id: package
Expand Down

0 comments on commit e3d7f52

Please sign in to comment.