Skip to content

Commit

Permalink
Modify workflows to run installation tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rluzuriaga authored Aug 15, 2024
1 parent 847eb0a commit 65402b1
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 48 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/stable-releases-1_pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,37 @@ name: Stable Release Step 1 - Create PR
on:
workflow_dispatch:
schedule:
- cron: "0 10 15 * *"
- cron: "0 15 16 * *"

jobs:
create-release-pull-request:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/stable'
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
ref: dev-branch
- name: create pull request
run: |
echo 'Get version to be released and create PR with that in the name'
system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php"
tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
gh pr create -B stable -H dev-branch --title "Stable Release PR For ${tag} - $(date '+%Y-%m-%d')" --body "Pull Request for creating the latest stable release from staged security fixes, bug fixes, and minor enhancements in dev-branch. Created as needed or monthly on 15th of every month, released once tests are passing"
env:
- uses: actions/checkout@v4
with:
ref: dev-branch

- name: Create pull request
run: |
echo 'Get version to be released and create PR with that in the name'
system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php"
tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
gh pr create -B stable -H dev-branch --title "Stable Release PR For ${tag} - $(date '+%Y-%m-%d')" --body "Pull Request for creating the latest stable release from staged security fixes, bug fixes, and minor enhancements in dev-branch. Created as needed or monthly on 15th of every month, released once tests are passing"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

call-test-validation-workflow:
needs: create-release-pull-request
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
ref: dev-branch

- name: Call test validity workflow
run: gh workflow run stable-releases-2_test-validity.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121 changes: 98 additions & 23 deletions .github/workflows/stable-releases-2_test-validity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,111 @@ name: Stable Release Step 2 - Validate PR

on:
workflow_dispatch:
# pull_request:
# types:
# - open
# branches:
# - dev-branch
# - stable
workflow_call:

jobs:
Merge-After-All-Tests-Passed:
runs-on: ubuntu-latest
run-install-tests:
runs-on: ubuntu-22.04

steps:
- name: Call main workflow that calls all the distros
run: gh workflow run --repo rluzuriaga/testing-distros execute_test_install_fog.yml
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_VALIDATION_REPO_TOKEN }}

check-all-tests-completed-successfully:
needs: run-install-tests
runs-on: ubuntu-22.04

env:
GITHUB_TOKEN: ${{ secrets.INSTALL_VALIDATION_REPO_TOKEN }}

steps:
- name: Wait a minute for the runs to start
run: sleep 60

- name: Get run IDs
run: |
run_id=$(gh run list --repo rluzuriaga/testing-distros --workflow execute_test_install_fog.yml --json databaseId --limit 1 | jq -r '.[0].databaseId')
echo "RUN_ID=$run_id" >> $GITHUB_ENV
- name: Check if distro workflow passed or failed
run: |
run_status=""
while [[ $run_status != "success" && $run_status != "failure" ]]; do
sleep 15
run_status=$(gh run view --repo rluzuriaga/testing-distros ${{ env.RUN_ID }} --exit-status --json conclusion | jq -r '.conclusion')
done
if [[ $run_status == "failure" ]]; then
exit 1
fi
merge-after-all-tests-passed:
needs: check-all-tests-completed-successfully

runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/stable'

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Merge The PR
run: |
echo 'Get the tag'
git fetch origin dev-branch
git checkout dev-branch
system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php"
tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
git checkout stable
echo "merge the pull request bringing dev-branch into stable";
gh pr merge dev-branch --squash --subject "Stable Release - ${tag}";
echo 'Get the tag'
git fetch origin dev-branch
git checkout dev-branch
system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php"
tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
git checkout stable
echo "merge the pull request bringing dev-branch into stable";
gh pr merge dev-branch --squash --subject "Stable Release - ${tag}";
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

close-pr-if-tests-fail:
needs: check-all-tests-completed-successfully

runs-on: ubuntu-22.04
if: failure()

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get PR number
run: |
pr_number=$(gh pr list --repo ${{ github.repository }} --json title,number | jq -r '.[] | select(.title | test("Stable Release PR for*"; "i")) | .number')
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
# on a monthly pr created from other workflow
# test validity of install
# down the road-test various functions (deploy, capture, API)
# Fix version if needed
# merge pull request with generic commit
# maybe update version if not handled in hook
- name: Close PR
run: |
closure_message="Closing PR due to failure in tests"
gh pr close --comment "$closure_message" ${{ env.PR_NUMBER }}
- name: Announce error on Discord
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
content: "Hey @everyone, validation tests failed. PR closed"
title: Validation tests
status: ${{ needs.check-all-tests-completed-successfully.result }}
color: 0xff0000

call-tag-and-release-workflow:
needs: merge-after-all-tests-passed
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
ref: stable

- name: Run tag and release workflow
run: gh workflow run stable-releases-3_tag-and-release.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39 changes: 26 additions & 13 deletions .github/workflows/stable-releases-3_tag-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ name: Stable Release Step 3 - Tag and Release

on:
workflow_dispatch:
# pull_request:
# types:
# - closed
workflow_call:

jobs:
Tag-and-release:
runs-on: ubuntu-latest
tag-and-release:
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/stable'

steps:
- name: Check-out code to release
uses: actions/checkout@v4

- name: Tag and release
run: |
echo 'Find the version to use for the tag, create the release, and sync the dev and stable branches'
Expand All @@ -26,12 +26,25 @@ jobs:
gh pr create -B dev-branch -H stable --title "merge stable - ${tag} into dev" --body "Pull Request for syncing stable release commit back to dev after a release"
gh pr merge stable --merge --subject "merge stable - ${tag} into dev";
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

discord-success:
needs: tag-and-release
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get tag as env
run: |
tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
echo "TAG=$tag" >> $GITHUB_ENV
# on merge of monthly release pr
# get/calculate current version
# create tag of current version
# create release of new tag
# generate release notes
# send announcements?
- name: Announce success on Discord
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "New release"
description: Click [here](https://github.com/fogproject/fogproject/releases/latest) to check the newest release.
color: 0x00ff00

0 comments on commit 65402b1

Please sign in to comment.