Skip to content

Commit 062c841

Browse files
authored
GH-39057: [CI][C++][Go] Don't run jobs that use a self-hosted GitHub Actions Runner on fork (#39903)
### Rationale for this change If jobs that use a self-hosted GitHub Actions Runner on fork are submitted on fork, they will timeout eventually and report noisy failure notifications. ### What changes are included in this PR? We can't use `jobs.<job_id>.if` to reject jobs that use self-hosted GitHub Actions Runner because `jobs.<job_id>.if` is evaluated before `jobs.<job_id>.strategy.matrix`. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif > Note: The `jobs.<job_id>.if` condition is evaluated before > `jobs.<job_id>.strategy.matrix` is applied. We can use output `jobs<job_id>.outputs` instead. See also: * https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs * https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * Closes: #39057 Authored-by: Sutou Kouhei <kou@clear-code.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 874e596 commit 062c841

2 files changed

Lines changed: 99 additions & 40 deletions

File tree

.github/workflows/cpp.yml

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,65 @@ env:
5757
DOCKER_VOLUME_PREFIX: ".docker/"
5858

5959
jobs:
60+
docker-targets:
61+
name: Docker targets
62+
runs-on: ubuntu-latest
63+
outputs:
64+
targets: ${{ steps.detect-targets.outputs.targets }}
65+
steps:
66+
- name: Detect targets
67+
id: detect-targets
68+
run: |
69+
echo "targets<<JSON" >> "$GITHUB_OUTPUT"
70+
echo "[" >> "$GITHUB_OUTPUT"
71+
cat <<JSON >> "$GITHUB_OUTPUT"
72+
{
73+
"arch": "amd64",
74+
"clang-tools": "14",
75+
"image": "conda-cpp",
76+
"llvm": "14",
77+
"runs-on": "ubuntu-latest",
78+
"simd-level": "AVX2",
79+
"title": "AMD64 Conda C++ AVX2",
80+
"ubuntu": "22.04"
81+
},
82+
{
83+
"arch": "amd64",
84+
"clang-tools": "14",
85+
"image": "ubuntu-cpp-sanitizer",
86+
"llvm": "14",
87+
"runs-on": "ubuntu-latest",
88+
"title": "AMD64 Ubuntu 22.04 C++ ASAN UBSAN",
89+
"ubuntu": "22.04"
90+
}
91+
JSON
92+
if [ "$GITHUB_REPOSITORY_OWNER" = "apache" ]; then
93+
echo "," >> "$GITHUB_OUTPUT"
94+
cat <<JSON >> "$GITHUB_OUTPUT"
95+
{
96+
"arch": "arm64v8",
97+
"clang-tools": "10",
98+
"image": "ubuntu-cpp",
99+
"llvm": "10",
100+
"runs-on": ["self-hosted", "arm", "linux"],
101+
"title": "ARM64 Ubuntu 20.04 C++",
102+
"ubuntu": "20.04"
103+
}
104+
JSON
105+
fi
106+
echo "]" >> "$GITHUB_OUTPUT"
107+
echo "JSON" >> "$GITHUB_OUTPUT"
108+
60109
docker:
61110
name: ${{ matrix.title }}
111+
needs: docker-targets
62112
runs-on: ${{ matrix.runs-on }}
63113
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
64114
timeout-minutes: 75
65115
strategy:
66116
fail-fast: false
67117
matrix:
68-
include:
69-
- arch: amd64
70-
clang-tools: "14"
71-
image: conda-cpp
72-
llvm: "14"
73-
runs-on: ubuntu-latest
74-
simd-level: AVX2
75-
title: AMD64 Conda C++ AVX2
76-
ubuntu: "22.04"
77-
- arch: amd64
78-
clang-tools: "14"
79-
image: ubuntu-cpp-sanitizer
80-
llvm: "14"
81-
runs-on: ubuntu-latest
82-
title: AMD64 Ubuntu 22.04 C++ ASAN UBSAN
83-
ubuntu: "22.04"
84-
- arch: arm64v8
85-
clang-tools: "10"
86-
image: ubuntu-cpp
87-
llvm: "10"
88-
runs-on: ["self-hosted", "arm", "linux"]
89-
title: ARM64 Ubuntu 20.04 C++
90-
ubuntu: "20.04"
118+
include: ${{ fromJson(needs.docker-targets.outputs.targets) }}
91119
env:
92120
ARCH: ${{ matrix.arch }}
93121
ARROW_SIMD_LEVEL: ${{ matrix.simd-level }}

.github/workflows/go.yml

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,62 @@ permissions:
4343

4444
jobs:
4545

46+
docker-targets:
47+
name: Docker targets
48+
runs-on: ubuntu-latest
49+
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
50+
outputs:
51+
targets: ${{ steps.detect-targets.outputs.targets }}
52+
steps:
53+
- name: Detect targets
54+
id: detect-targets
55+
run: |
56+
echo "targets<<JSON" >> "$GITHUB_OUTPUT"
57+
echo "[" >> "$GITHUB_OUTPUT"
58+
cat <<JSON >> "$GITHUB_OUTPUT"
59+
{
60+
"arch-label": "AMD64",
61+
"arch": "amd64",
62+
"go": "1.19",
63+
"runs-on": "ubuntu-latest"
64+
},
65+
{
66+
"arch-label": "AMD64",
67+
"arch": "amd64",
68+
"go": "1.20",
69+
"runs-on": "ubuntu-latest"
70+
}
71+
JSON
72+
if [ "$GITHUB_REPOSITORY_OWNER" = "apache" ]; then
73+
echo "," >> "$GITHUB_OUTPUT"
74+
cat <<JSON >> "$GITHUB_OUTPUT"
75+
{
76+
"arch-label": "ARM64",
77+
"arch": "arm64v8",
78+
"go": "1.19",
79+
"runs-on": ["self-hosted", "arm", "linux"]
80+
},
81+
{
82+
"arch-label": "ARM64",
83+
"arch": "arm64v8",
84+
"go": "1.20",
85+
"runs-on": ["self-hosted", "arm", "linux"]
86+
}
87+
JSON
88+
fi
89+
echo "]" >> "$GITHUB_OUTPUT"
90+
echo "JSON" >> "$GITHUB_OUTPUT"
91+
4692
docker:
4793
name: ${{ matrix.arch-label }} Debian 11 Go ${{ matrix.go }}
94+
needs: docker-targets
4895
runs-on: ${{ matrix.runs-on }}
4996
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
5097
timeout-minutes: 60
5198
strategy:
5299
fail-fast: false
53100
matrix:
54-
include:
55-
- arch-label: AMD64
56-
arch: amd64
57-
go: 1.19
58-
runs-on: ubuntu-latest
59-
- arch-label: AMD64
60-
arch: amd64
61-
go: '1.20'
62-
runs-on: ubuntu-latest
63-
- arch-label: ARM64
64-
arch: arm64v8
65-
go: 1.19
66-
runs-on: ["self-hosted", "arm", "linux"]
67-
- arch-label: ARM64
68-
arch: arm64v8
69-
go: '1.20'
70-
runs-on: ["self-hosted", "arm", "linux"]
101+
include: ${{ fromJson(needs.docker-targets.outputs.targets) }}
71102
env:
72103
ARCH: ${{ matrix.arch }}
73104
GO: ${{ matrix.go }}

0 commit comments

Comments
 (0)