Skip to content

Commit 7dc7152

Browse files
committed
Migrate to GH action for presubmit ci jobs
1 parent a52a0c4 commit 7dc7152

1 file changed

Lines changed: 176 additions & 0 deletions

File tree

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: Triggers CI Presubmit Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- release-*
8+
9+
issue_comment:
10+
types: [created]
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
contents: read
18+
pull-requests: write
19+
20+
env:
21+
SHELL: /bin/bash
22+
GOPATH: ${{ github.workspace }}
23+
GO111MODULE: on
24+
KIND_CLUSTER_NAME: tekton-triggers
25+
26+
jobs:
27+
prepare-pr-check:
28+
if: |
29+
github.event.issue.pull_request &&
30+
(
31+
startsWith(github.event.comment.body, '/ok-to-test') ||
32+
startsWith(github.event.comment.body, '/retest')
33+
)
34+
name: Check PR Author / ok-to-test
35+
runs-on: ubuntu-latest
36+
outputs:
37+
run_tests: ${{ steps.check.outputs.run_tests }}
38+
steps:
39+
- name: Install Python yq
40+
run: |
41+
python3 -m pip install --user yq
42+
43+
- name: Check PR author against org.yaml or /ok-to-test label
44+
id: check
45+
run: |
46+
echo "Fetching Tekton org.yaml..."
47+
ORG_YAML_URL="https://raw.githubusercontent.com/tektoncd/community/refs/heads/main/org/org.yaml"
48+
ORG_YAML=$(curl -sSL "$ORG_YAML_URL")
49+
50+
# Use Python yq (wraps jq) to extract members and admins
51+
IS_MEMBER=$(echo "$ORG_YAML" | ~/.local/bin/yq -r '.orgs.tektoncd.members[]' | grep -Fx "$GITHUB_ACTOR" || true)
52+
IS_ADMIN=$(echo "$ORG_YAML" | ~/.local/bin/yq -r '.orgs.tektoncd.admins[]' | grep -Fx "$GITHUB_ACTOR" || true)
53+
54+
if [[ -n "$IS_MEMBER" || -n "$IS_ADMIN" ]]; then
55+
echo " $GITHUB_ACTOR is a Tekton org member or admin."
56+
echo "run_tests=true" >> "$GITHUB_OUTPUT"
57+
else
58+
echo " $GITHUB_ACTOR is NOT a Tekton org member/admin. Checking for /ok-to-test label..."
59+
60+
LABELS=$(jq -r '.pull_request.labels[].name' < "$GITHUB_EVENT_PATH")
61+
if echo "$LABELS" | grep -q '^ok-to-test$'; then
62+
echo " /ok-to-test label found."
63+
echo "run_tests=true" >> "$GITHUB_OUTPUT"
64+
else
65+
echo " Not a member and no /ok-to-test label. Skipping tests."
66+
echo "run_tests=false" >> "$GITHUB_OUTPUT"
67+
fi
68+
fi
69+
env:
70+
GITHUB_ACTOR: ${{ github.actor }}
71+
72+
unit-tests:
73+
name: Unit Tests
74+
needs: prepare-pr-check
75+
runs-on: ubuntu-latest
76+
if: needs.prepare-pr-check.outputs.run_tests == 'true'
77+
steps:
78+
- name: Checkout
79+
uses: actions/checkout@v4
80+
with:
81+
path: ${{ github.workspace }}/src/github.com/tektoncd/triggers
82+
83+
- name: Set up Go
84+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
85+
with:
86+
cache-dependency-path: src/github.com/tektoncd/triggers/go.sum
87+
go-version-file: src/github.com/tektoncd/triggers/go.mod
88+
89+
- name: Install dependencies
90+
run: |
91+
go install github.com/jstemmer/go-junit-report@v0.9.1
92+
mkdir -p "${ARTIFACTS:-/tmp/artifacts}"
93+
echo "${GOPATH}/bin" >> "$GITHUB_PATH"
94+
95+
- name: Run Unit Tests
96+
working-directory: ${{ github.workspace }}/src/github.com/tektoncd/triggers
97+
run: ./test/presubmit-tests.sh --unit-tests
98+
99+
integration-tests:
100+
name: Integration Tests
101+
needs: prepare-pr-check
102+
runs-on: ubuntu-latest
103+
if: needs.prepare-pr-check.outputs.run_tests == 'true'
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
107+
with:
108+
path: ${{ github.workspace }}/src/github.com/tektoncd/triggers
109+
110+
- name: Set up Go
111+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
112+
with:
113+
cache-dependency-path: src/github.com/tektoncd/triggers/go.sum
114+
go-version-file: src/github.com/tektoncd/triggers/go.mod
115+
116+
- name: Install dependencies (ko, kind, kubectl, go-junit-report)
117+
run: |
118+
echo '::group::install ko'
119+
curl -L https://github.com/ko-build/ko/releases/download/v0.15.4/ko_0.15.4_Linux_x86_64.tar.gz | tar xzf - ko
120+
chmod +x ./ko && sudo mv ko /usr/local/bin
121+
echo '::endgroup::'
122+
123+
echo '::group::install kind'
124+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64
125+
chmod +x ./kind && sudo mv ./kind /usr/local/bin/kind
126+
echo '::endgroup::'
127+
128+
echo '::group::install kubectl'
129+
curl -LO "https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
130+
chmod +x kubectl && sudo mv kubectl /usr/local/bin/kubectl
131+
echo '::endgroup::'
132+
133+
echo '::group::install go-junit-report'
134+
go install github.com/jstemmer/go-junit-report@v0.9.1
135+
echo '::endgroup::'
136+
137+
mkdir -p "${ARTIFACTS:-/tmp/artifacts}"
138+
echo "${GOPATH}/bin" >> "$GITHUB_PATH"
139+
140+
- name: Run Integration Tests
141+
working-directory: ${{ github.workspace }}/src/github.com/tektoncd/triggers
142+
run: ./test/presubmit-tests.sh --integration-tests
143+
144+
build-tests:
145+
name: Build Tests
146+
needs: prepare-pr-check
147+
runs-on: ubuntu-latest
148+
if: needs.prepare-pr-check.outputs.run_tests == 'true'
149+
steps:
150+
- name: Checkout
151+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
152+
with:
153+
path: ${{ github.workspace }}/src/github.com/tektoncd/triggers
154+
155+
- name: Set up Go
156+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
157+
with:
158+
cache-dependency-path: src/github.com/tektoncd/triggers/go.sum
159+
go-version-file: src/github.com/tektoncd/triggers/go.mod
160+
161+
- name: Install dependencies (go-junit-report, go-licenses)
162+
run: |
163+
echo '::group::install go-junit-report'
164+
go install github.com/jstemmer/go-junit-report@v0.9.1
165+
echo '::endgroup::'
166+
167+
echo '::group::install go-licenses'
168+
go install github.com/google/go-licenses@latest
169+
echo '::endgroup::'
170+
171+
mkdir -p "${ARTIFACTS:-/tmp/artifacts}"
172+
echo "${GOPATH}/bin" >> "$GITHUB_PATH"
173+
174+
- name: Run Build Tests
175+
working-directory: ${{ github.workspace }}/src/github.com/tektoncd/triggers
176+
run: ./test/presubmit-tests.sh --build-tests

0 commit comments

Comments
 (0)