Skip to content

Commit

Permalink
Github Actions: workaround for undefined env
Browse files Browse the repository at this point in the history
  • Loading branch information
tsionyx committed Mar 27, 2024
1 parent 0800a4e commit 101062c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/1_static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@ env:
APT_DEPENDENCIES: "['libasound2-dev']"

jobs:
get-env-vars:
name: Get Environment vars
runs-on: ubuntu-latest
outputs:
RUST_VERSIONS: ${{ env.RUST_VERSIONS }}
APT_DEPENDENCIES: ${{ env.APT_DEPENDENCIES }}
steps:
- run: echo "null"

fmt:
name: Rustfmt on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars ]
strategy:
matrix:
# https://github.com/orgs/community/discussions/46785#discussioncomment-4909718
rust: ${{ fromJSON(env.RUST_VERSIONS) }}
# https://github.com/actions/runner/issues/2372#issuecomment-1591370444
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand All @@ -44,9 +55,10 @@ jobs:
clippy:
name: Clippy on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars ]
strategy:
matrix:
rust: ${{ fromJSON(env.RUST_VERSIONS) }}
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand All @@ -55,8 +67,8 @@ jobs:

- name: Install deps
# https://github.com/orgs/community/discussions/27125#discussioncomment-3254720
if: ${{ fromJSON(env.APT_DEPENDENCIES)[0] != null }}
run: sudo apt-get -y install ${{ join(fromJSON(env.APT_DEPENDENCIES), ' ') }}
if: ${{ fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES)[0] != null }}
run: sudo apt-get -y install ${{ join(fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES), ' ') }}

- name: Install toolchain
uses: actions-rs/toolchain@v1
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/2_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,34 @@ env:
APT_DEPENDENCIES: "['libasound2-dev']"

jobs:
get-env-vars:
name: Get Environment vars
runs-on: ubuntu-latest
outputs:
RUST_VERSIONS: ${{ env.RUST_VERSIONS }}
APT_DEPENDENCIES: ${{ env.APT_DEPENDENCIES }}
steps:
- run: echo "null"

test:
name: Test Suite on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars ]

# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' }}
strategy:
matrix:
rust: ${{ fromJSON(env.RUST_VERSIONS) }}
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive

- name: Install deps
if: ${{ fromJSON(env.APT_DEPENDENCIES)[0] != null }}
run: sudo apt-get -y install ${{ join(fromJSON(env.APT_DEPENDENCIES), ' ') }}
if: ${{ fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES)[0] != null }}
run: sudo apt-get -y install ${{ join(fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES), ' ') }}

- name: Install toolchain
uses: actions-rs/toolchain@v1
Expand Down

0 comments on commit 101062c

Please sign in to comment.