Skip to content

Commit 8576e2a

Browse files
committed
ci: Add workflow for ci_test bad, use remote fmf plan
* Remove plan from role dir, it's too complicated and long to run tests from tmt * Use plan from linux-system-roles/tft-tests * Move getting datetime to testing-farm job where it's used * Add a workflow for running [citest_bad] * Bump sclorg/testing-farm-as-github-action to v3 * Move concurrency group to first job * Dump GitHub context Signed-off-by: Sergei Petrosian <[email protected]>
1 parent 93f2410 commit 8576e2a

File tree

5 files changed

+77
-98
lines changed

5 files changed

+77
-98
lines changed

.github/workflows/tft.yml

+33-23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Run integration tests in Testing Farm
23
on:
34
issue_comment:
@@ -7,26 +8,32 @@ permissions:
78
contents: read
89
# This is required for the ability to create/update the Pull request status
910
statuses: write
10-
# The concurrency key is used to prevent multiple workflows from running at the same time
11-
concurrency:
12-
# group name contains reponame-pr_num to allow simualteneous runs in different PRs
13-
group: testing-farm-${{ github.event.repository.name }}-${{ github.event.issue.number }}
14-
cancel-in-progress: true
1511
jobs:
1612
prepare_vars:
1713
name: Get info from role and PR to determine if and how to test
14+
# The concurrency key is used to prevent multiple workflows from running at the same time
15+
concurrency:
16+
# group name contains reponame-pr_num to allow simualteneous runs in different PRs
17+
group: testing-farm-${{ github.event.repository.name }}-${{ github.event.issue.number }}
18+
cancel-in-progress: true
1819
# Let's schedule tests only on user request. NOT automatically.
1920
# Only repository owner or member can schedule tests
2021
if: |
2122
github.event.issue.pull_request
22-
&& (contains(github.event.comment.body, '[citest]') || contains(github.event.comment.body, '[citest-all]'))
23+
&& contains(github.event.comment.body, '[citest]')
24+
&& (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.comment.author_association)
25+
|| contains('systemroller', github.event.comment.user.login))
2326
runs-on: ubuntu-latest
2427
outputs:
2528
supported_platforms: ${{ steps.supported_platforms.outputs.supported_platforms }}
2629
head_sha: ${{ steps.head_sha.outputs.head_sha }}
27-
datetime: ${{ steps.datetime.outputs.datetime }}
2830
memory: ${{ steps.memory.outputs.memory }}
2931
steps:
32+
- name: Dump github context
33+
run: echo "$GITHUB_CONTEXT"
34+
shell: bash
35+
env:
36+
GITHUB_CONTEXT: ${{ toJson(github) }}
3037

3138
- name: Checkout repo
3239
uses: actions/checkout@v4
@@ -41,12 +48,6 @@ jobs:
4148
PR_NO: ${{ github.event.issue.number }}
4249
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4350

44-
- name: Get cuurent datetime
45-
id: datetime
46-
run: |
47-
printf -v datetime '%(%Y%m%d-%H%M%S)T' -1
48-
echo "datetime=$datetime" >> $GITHUB_OUTPUT
49-
5051
- name: Get memory
5152
id: memory
5253
run: |
@@ -114,6 +115,19 @@ jobs:
114115
${{ needs.prepare_vars.outputs.datetime }}/artifacts"
115116
ARTIFACT_TARGET_DIR: /srv/pub/alt/linuxsystemroles/logs
116117
steps:
118+
- name: Set variables with DATETIME and artifact location
119+
id: set_vars
120+
run: |
121+
printf -v DATETIME '%(%Y%m%d-%H%M%S)T' -1
122+
ARTIFACTS_DIR_NAME="tf_${{ github.event.repository.name }}-${{ github.event.issue.number }}_\
123+
${{ matrix.platform }}-${{ matrix.ansible_version }}_$DATETIME/artifacts"
124+
ARTIFACTS_TARGET_DIR=/srv/pub/alt/linuxsystemroles/logs
125+
ARTIFACTS_DIR=$ARTIFACTS_TARGET_DIR/$ARTIFACTS_DIR_NAME
126+
ARTIFACTS_URL=https://dl.fedoraproject.org/pub/alt/linuxsystemroles/logs$ARTIFACTS_DIR_NAME
127+
echo "DATETIME=$DATETIME" >> $GITHUB_OUTPUT
128+
echo "ARTIFACTS_DIR=$ARTIFACTS_DIR" >> $GITHUB_OUTPUT
129+
echo "ARTIFACTS_URL=$ARTIFACTS_URL" >> $GITHUB_OUTPUT
130+
117131
- name: Set commit status as pending
118132
if: contains(needs.prepare_vars.outputs.supported_platforms, matrix.platform)
119133
uses: myrotvorets/set-commit-status-action@master
@@ -137,19 +151,17 @@ jobs:
137151
- name: Run test in testing farm
138152
uses: sclorg/testing-farm-as-github-action@v3
139153
if: contains(needs.prepare_vars.outputs.supported_platforms, matrix.platform)
140-
env:
141-
ARTIFACTS_DIR: ${{ env.ARTIFACT_TARGET_DIR }}/${{ env.ARTIFACTS_DIR_NAME }}
142-
ARTIFACTS_URL: https://dl.fedoraproject.org/pub/alt/linuxsystemroles/logs/${{ env.ARTIFACTS_DIR_NAME }}
143154
with:
144-
git_url: ${{ github.server_url }}/${{ github.repository }}
145-
git_ref: ${{ needs.prepare_vars.outputs.head_sha }}
155+
git_url: https://github.com/linux-system-roles/tft-tests
156+
git_ref: main
146157
pipeline_settings: '{ "type": "tmt-multihost" }'
147158
variables: "ANSIBLE_VER=${{ matrix.ansible_version }};\
148159
REPO_NAME=${{ github.event.repository.name }};\
160+
GITHUB_ORG=${{ github.repository_owner }};\
149161
GITHUB_ORG=linux-system-roles;\
150162
PR_NUM=${{ github.event.issue.number }};\
151-
ARTIFACTS_DIR=${{ env.ARTIFACTS_DIR }};\
152-
ARTIFACTS_URL=${{ env.ARTIFACTS_URL }};\
163+
ARTIFACTS_DIR=${{ steps.set_vars.outputs.ARTIFACTS_DIR }};\
164+
ARTIFACTS_URL=${{ steps.set_vars.outputs.ARTIFACTS_URL }};\
153165
TEST_LOCAL_CHANGES=false"
154166
# Note that LINUXSYSTEMROLES_SSH_KEY must be single-line, TF doesn't read multi-line variables fine.
155167
secrets: "LINUXSYSTEMROLES_USER=${{ secrets.LINUXSYSTEMROLES_USER }};\
@@ -167,11 +179,9 @@ jobs:
167179
- name: Set final commit status
168180
uses: myrotvorets/set-commit-status-action@master
169181
if: always() && contains(needs.prepare_vars.outputs.supported_platforms, matrix.platform)
170-
env:
171-
ARTIFACTS_URL: https://dl.fedoraproject.org/pub/alt/linuxsystemroles/logs/${{ env.ARTIFACTS_DIR_NAME }}
172182
with:
173183
sha: ${{ needs.prepare_vars.outputs.head_sha }}
174184
status: ${{ job.status }}
175185
context: ${{ matrix.platform }}|ansible-${{ matrix.ansible_version }}
176186
description: Test finished
177-
targetUrl: ${{ env.ARTIFACTS_URL }}
187+
targetUrl: ${{ steps.set_vars.outputs.ARTIFACTS_URL }}

.github/workflows/tft_citest_bad.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Re-run failed testing farm tests
3+
on:
4+
issue_comment:
5+
types:
6+
- created
7+
permissions:
8+
contents: read
9+
jobs:
10+
citest_bad_rerun:
11+
if: |
12+
github.event.issue.pull_request
13+
&& github.event.comment.body == '[citest_bad]'
14+
&& contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.comment.author_association)
15+
permissions:
16+
actions: write # for re-running failed jobs: https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#re-run-a-job-from-a-workflow-run
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Wait 10s until tft.yml workflow is created and skipped because new comment don't match [citest]
20+
run: sleep 10s
21+
22+
- name: Re-run failed jobs for this PR
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
REPO: ${{ github.repository }}
26+
PR_TITLE: ${{ github.event.issue.title }}
27+
run: |
28+
PENDING_RUN=$(gh api "repos/$REPO/actions/workflows/tft.yml/runs?event=issue_comment" \
29+
| jq -r "[.workflow_runs[] | select( .display_title == \"$PR_TITLE\") | \
30+
select(.status == \"pending\" or .status == \"queued\" or .status == \"in_progress\") | .id][0]")
31+
# if pending run don't exist, take the last run with failure state
32+
if [ "$PENDING_RUN" != "null" ]; then
33+
echo "The workflow $PENDING_RUN is still running, wait for it to finish to re-run"
34+
exit 1
35+
fi
36+
RUN_ID=$(gh api "repos/$REPO/actions/workflows/tft.yml/runs?event=issue_comment" \
37+
| jq -r "[.workflow_runs[] | select( .display_title == \"$PR_TITLE\" ) | select( .conclusion == \"failure\" ) | .id][0]")
38+
if [ "$RUN_ID" = "null" ]; then
39+
echo "Failed workflow not found, exitting"
40+
exit 1
41+
fi
42+
echo "Re-running workflow $RUN_ID"
43+
gh api --method POST repos/$REPO/actions/runs/$RUN_ID/rerun-failed-jobs

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PostgreSQL system role
22

3-
[![ansible-lint.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/ansible-lint.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/ansible-lint.yml) [![ansible-test.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/ansible-test.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/ansible-test.yml) [![markdownlint.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/markdownlint.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/markdownlint.yml) [![tft.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/tft.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/tft.yml) [![woke.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/woke.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/woke.yml)
3+
[![ansible-lint.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/ansible-lint.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/ansible-lint.yml) [![ansible-test.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/ansible-test.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/ansible-test.yml) [![markdownlint.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/markdownlint.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/markdownlint.yml) [![tft.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/tft.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/tft.yml) [![tft_citest_bad.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/tft_citest_bad.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/tft_citest_bad.yml) [![woke.yml](https://github.com/linux-system-roles/postgresql/actions/workflows/woke.yml/badge.svg)](https://github.com/linux-system-roles/postgresql/actions/workflows/woke.yml)
44

55
The PostgreSQL system role installs, configures, and starts the PostgreSQL
66
server.

plans/README-plans.md

-30
This file was deleted.

plans/general.fmf

-44
This file was deleted.

0 commit comments

Comments
 (0)