ci: migrate tests to reusable workflows and introduce stable-tag pipeline
- convert all test workflows to reusable workflow_call - add central CI workflow for branches and PRs - add mark-stable workflow triggered on main pushes - ensure stable tag updates only after all tests succeed - remove duplicated triggers from test workflows ` https://chatgpt.com/share/693aa4a6-7460-800f-ba47-cfc15b1b2236
This commit is contained in:
26
.github/workflows/ci.yml
vendored
Normal file
26
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-unit:
|
||||||
|
uses: ./.github/workflows/test-unit.yml
|
||||||
|
|
||||||
|
test-integration:
|
||||||
|
uses: ./.github/workflows/test-integration.yml
|
||||||
|
|
||||||
|
test-container:
|
||||||
|
uses: ./.github/workflows/test-container.yml
|
||||||
|
|
||||||
|
test-e2e:
|
||||||
|
uses: ./.github/workflows/test-e2e.yml
|
||||||
|
|
||||||
|
test-virgin-user:
|
||||||
|
uses: ./.github/workflows/test-virgin-user.yml
|
||||||
|
|
||||||
|
test-virgin-root:
|
||||||
|
uses: ./.github/workflows/test-virgin-root.yml
|
||||||
109
.github/workflows/mark-stable.yml
vendored
109
.github/workflows/mark-stable.yml
vendored
@@ -1,27 +1,41 @@
|
|||||||
name: Mark stable commit
|
name: Mark stable commit
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
push:
|
||||||
workflows:
|
branches:
|
||||||
- Test Units
|
- main
|
||||||
- Test Code Integration
|
|
||||||
- Test OS Containers
|
|
||||||
- Test End-To-End
|
|
||||||
- Test Virgin User
|
|
||||||
- Test Virgin Root
|
|
||||||
types:
|
|
||||||
- completed
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test-unit:
|
||||||
|
uses: ./.github/workflows/test-unit.yml
|
||||||
|
|
||||||
|
test-integration:
|
||||||
|
uses: ./.github/workflows/test-integration.yml
|
||||||
|
|
||||||
|
test-container:
|
||||||
|
uses: ./.github/workflows/test-container.yml
|
||||||
|
|
||||||
|
test-e2e:
|
||||||
|
uses: ./.github/workflows/test-e2e.yml
|
||||||
|
|
||||||
|
test-virgin-user:
|
||||||
|
uses: ./.github/workflows/test-virgin-user.yml
|
||||||
|
|
||||||
|
test-virgin-root:
|
||||||
|
uses: ./.github/workflows/test-virgin-root.yml
|
||||||
|
|
||||||
mark-stable:
|
mark-stable:
|
||||||
if: >
|
needs:
|
||||||
github.event.workflow_run.conclusion == 'success' &&
|
- test-unit
|
||||||
github.event.workflow_run.head_branch == 'main'
|
- test-integration
|
||||||
|
- test-container
|
||||||
|
- test-e2e
|
||||||
|
- test-virgin-user
|
||||||
|
- test-virgin-root
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write # to move the tag
|
||||||
actions: read
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -29,73 +43,22 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Install jq and gh
|
- name: Move 'stable' tag to this commit
|
||||||
run: |
|
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install -y jq gh || true
|
|
||||||
|
|
||||||
- name: Check all required workflow results for this commit
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
SHA: ${{ github.event.workflow_run.head_sha }}
|
|
||||||
REPO: ${{ github.event.workflow_run.repository.full_name }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
echo "Commit: $SHA"
|
|
||||||
echo "Repository: $REPO"
|
|
||||||
echo "Fetching workflow runs…"
|
|
||||||
|
|
||||||
required_workflows=(
|
|
||||||
"Test Units"
|
|
||||||
"Test Code Integration"
|
|
||||||
"Test OS Containers"
|
|
||||||
"Test End-To-End"
|
|
||||||
"Test Virgin User"
|
|
||||||
"Test Virgin Root"
|
|
||||||
)
|
|
||||||
|
|
||||||
# FIX: cannot filter by head_sha — GitHub API bug!
|
|
||||||
json=$(gh api /repos/"$REPO"/actions/runs -F per_page=100 -F event=workflow_run)
|
|
||||||
|
|
||||||
for wf in "${required_workflows[@]}"; do
|
|
||||||
conclusion=$(printf '%s\n' "$json" | jq -r --arg name "$wf" --arg sha "$SHA" '
|
|
||||||
.workflow_runs[]
|
|
||||||
| select(.name == $name and .head_sha == $sha)
|
|
||||||
| .conclusion
|
|
||||||
' | head -n1)
|
|
||||||
|
|
||||||
if [[ -z "$conclusion" || "$conclusion" == "null" ]]; then
|
|
||||||
echo "❌ Workflow '$wf' has no run for this commit yet."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$conclusion" != "success" ]]; then
|
|
||||||
echo "❌ Workflow '$wf' did not succeed (status: $conclusion)."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "✔ Workflow '$wf' succeeded."
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "🎉 All tests succeeded — this commit is STABLE."
|
|
||||||
|
|
||||||
- name: Move 'stable' tag
|
|
||||||
env:
|
|
||||||
SHA: ${{ github.event.workflow_run.head_sha }}
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
echo "Tagging commit $SHA as stable…"
|
echo "Tagging commit $GITHUB_SHA as stable…"
|
||||||
|
|
||||||
|
# delete local tag if exists
|
||||||
git tag -d stable 2>/dev/null || true
|
git tag -d stable 2>/dev/null || true
|
||||||
|
# delete remote tag if exists
|
||||||
git push origin :refs/tags/stable || true
|
git push origin :refs/tags/stable || true
|
||||||
|
|
||||||
git tag stable "$SHA"
|
# create new tag on this commit
|
||||||
|
git tag stable "$GITHUB_SHA"
|
||||||
git push origin stable
|
git push origin stable
|
||||||
|
|
||||||
echo "✅ Done."
|
echo "✅ Stable tag updated."
|
||||||
|
|||||||
8
.github/workflows/test-container.yml
vendored
8
.github/workflows/test-container.yml
vendored
@@ -1,13 +1,7 @@
|
|||||||
name: Test OS Containers
|
name: Test OS Containers
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_call:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- "*"
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-container:
|
test-container:
|
||||||
|
|||||||
8
.github/workflows/test-e2e.yml
vendored
8
.github/workflows/test-e2e.yml
vendored
@@ -1,13 +1,7 @@
|
|||||||
name: Test End-To-End
|
name: Test End-To-End
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_call:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- "*"
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-e2e:
|
test-e2e:
|
||||||
|
|||||||
8
.github/workflows/test-integration.yml
vendored
8
.github/workflows/test-integration.yml
vendored
@@ -1,13 +1,7 @@
|
|||||||
name: Test Code Integration
|
name: Test Code Integration
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_call:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- "*"
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-integration:
|
test-integration:
|
||||||
|
|||||||
8
.github/workflows/test-unit.yml
vendored
8
.github/workflows/test-unit.yml
vendored
@@ -1,13 +1,7 @@
|
|||||||
name: Test Units
|
name: Test Units
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_call:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- "*"
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-unit:
|
test-unit:
|
||||||
|
|||||||
8
.github/workflows/test-virgin-root.yml
vendored
8
.github/workflows/test-virgin-root.yml
vendored
@@ -1,13 +1,7 @@
|
|||||||
name: Test Virgin Root
|
name: Test Virgin Root
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_call:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- "*"
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-virgin-root:
|
test-virgin-root:
|
||||||
|
|||||||
8
.github/workflows/test-virgin-user.yml
vendored
8
.github/workflows/test-virgin-user.yml
vendored
@@ -1,13 +1,7 @@
|
|||||||
name: Test Virgin User
|
name: Test Virgin User
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_call:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- "*"
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-virgin-user:
|
test-virgin-user:
|
||||||
|
|||||||
Reference in New Issue
Block a user