admin管理员组文章数量:1398819
I'm trying to configure a GitHub Actions workflow where all tests run sequentially on a single runner instance without spawning multiple runners of the same type.
What I Want to Achieve:
- I have a matrix of tests and runner types.
- For each runner type, I want all the tests to run one after another (sequentially) instead of running in parallel. As I don't want GitHub Actions to scale up and create multiple runners of the same type.
- However, if I have different runner types (e.g.,
t4g.small
,t4g.medium
,t4g.large
), I want those to run in parallel on their respective instances.
Example Scenario:
- Runners:
t4g.small
,t4g.medium
,t4g.large
- Tests:
test1
,test2
,test3
Expected Execution:
- On
t4g.small
:test1 → test2 → test3
(Sequentially) - On
t4g.medium
:test1 → test2 → test3
(Sequentially) - On
t4g.large
:test1 → test2 → test3
(Sequentially)
All three runners can run in parallel, but each test within a runner should queue up and run one after another.
What I Tried:
- Using
concurrency
with Matrix Strategy:
concurrency:
group: "${{ matrix.instance_type }}"
cancel-in-progress: false
- This didn't work as expected. It canceled jobs in progress with messages like:
Canceling since a higher priority waiting request for ... exists
- Using Queuing with
max-parallel: 1
:
strategy:
max-parallel: 1
- This applied globally, limiting the total number of jobs, which is not what I wanted.
My Current Workflow Code:
name: Concurrency Test
on:
push:
branches:
- main
jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
instance_types: ${{ steps.set-output.outputs.instance_types }}
tests: ${{ steps.set-output.outputs.tests }}
steps:
- name: Set Matrix Variables
id: set-output
run: |
echo 'instance_types=["t4g.small","t4g.medium","t4g.large"]' >> $GITHUB_OUTPUT
echo 'tests=["test1","test2","test3"]' >> $GITHUB_OUTPUT
run-tests:
name: Run ${{ matrix.test }} on ${{ matrix.instance_type }}
needs: setup-matrix
runs-on: ${{ matrix.instance_type }}
strategy:
fail-fast: false
matrix:
instance_type: ${{ fromJson(needs.setup-matrix.outputs.instance_types) }}
test: ${{ fromJson(needs.setup-matrix.outputs.tests) }}
concurrency:
group: ${{ matrix.instance_type }}
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize Counter
run: echo "COUNTER=0" >> $GITHUB_ENV
- name: Increment Counter
run: |
COUNTER=$((COUNTER+1))
echo "COUNTER=$COUNTER" >> $GITHUB_ENV
echo "Running Job Number: $COUNTER for ${{ matrix.instance_type }} ${{ matrix.test }}"
- name: Simulate Task
run: sleep 5
Question:
- How can I configure GitHub Actions to ensure all tests on a single runner type run sequentially while still allowing different runner types to run in parallel?
- Is there a way to queue up jobs for a specific runner type without relying on
concurrency
canceling jobs?
Any suggestions or workarounds would be greatly appreciated!
本文标签:
版权声明:本文标题:How to Run All Tests Sequentially on a Single GitHub Actions Runner Without Spawning Additional Runners? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744122760a2591816.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论