Skip to content

Commit

Permalink
ci: Trigger and check generated project's CI
Browse files Browse the repository at this point in the history
Issue-24: #24
  • Loading branch information
pawamoy committed May 24, 2024
1 parent 30d3bc9 commit f75014f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,30 @@ jobs:

- name: Test project generation and workflow
run: bash tests/test_project.sh

test-project-ci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config --global init.defaultBranch main
git config --global user.email "dev@pawamoy.fr"
git config --global user.name "Timothée Mazzucotelli"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Copier and uv
run: pip install copier copier-templates-extensions uv

- name: Trigger and wait project's own CI
env:
GH_TOKEN: ${{ secrets.TESTING_PUSH_TOKEN }}
run: bash tests/wait_ci.sh
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ test: cleantests
@bash tests/test_project.sh
@.venv/bin/python tests/test_licenses.py

wait-ci:
@bash tests/wait_ci.sh

DUTIES = \
test-changelog \
test-check \
Expand Down
11 changes: 8 additions & 3 deletions tests/reset_history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
cd tests/tmp || exit 1
rm -rf .git
git init .
git remote add origin git@github.com:pawamoy/pawamoy-testing
if [ -n "${GH_TOKEN}" ]; then
git remote add origin https://pawamoy:${GH_TOKEN}@github.com/pawamoy/pawamoy-testing.git
else
git remote add origin git@github.com:pawamoy/pawamoy-testing.git
fi
git add -A
git commit -m "initial commit"
git push origin main -f
git commit -m "feat: Initial commit"
git tag 0.1.0
git push origin main -f --tags
40 changes: 40 additions & 0 deletions tests/wait_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
echo "Fetching previous run number..."
previous_run=$(gh run list --repo pawamoy/pawamoy-testing --branch 0.1.0 --limit 1 --workflow "ci.yml" --json number --jq ".[0].number")

echo "Resetting project's Git history..."
rm -rf tests/tmp/*
make reset-history
cd tests/tmp || exit 1

wait_time=20
echo "Waiting project's workflow completion (${wait_time}s iterations)..."
while true; do
if output=$(gh run list --repo pawamoy/pawamoy-testing --branch 0.1.0 --limit 1 --workflow "ci.yml" --json number,status,conclusion); then
number=$(jq -r ".[0].number" <<< "$output")
if [ "${number}" -gt "${previous_run}" ]; then
status=$(jq -r ".[0].status" <<< "$output")
if [ "${status}" = "completed" ]; then
conclusion=$(jq -r ".[0].conclusion" <<< "$output")
echo "Workflow completed: ${conclusion}"
if [ "${conclusion}" = "success" ]; then
break
else
exit 1
fi
else
echo "Workflow status: ${status}"
fi
else
echo "Workflow not created"
fi
else
echo "Workflow not created"
fi
sleep ${wait_time}
done

echo "Deleting all testing releases..."
for tag in $(gh release list --repo pawamoy/pawamoy-testing --json tagName --jq ".[].tagName"); do
gh release delete "${tag}" --repo pawamoy/pawamoy-testing --yes --cleanup-tag
done

0 comments on commit f75014f

Please sign in to comment.