ci: Fix fetching previous run number #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
push: | |
pull_request: | |
branches: | |
- main | |
defaults: | |
run: | |
shell: bash | |
env: | |
LANG: "en_US.utf-8" | |
LC_ALL: "en_US.utf-8" | |
PYTHONIOENCODING: "UTF-8" | |
PYTHON_VERSIONS: "" | |
jobs: | |
test-filenames: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Test file names | |
run: bash tests/test_filenames.sh | |
test-licenses: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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.11" | |
- name: Install Jinja2 | |
run: pip install jinja2 | |
- name: Test licenses | |
run: python tests/test_licenses.py | |
# test-project: | |
# strategy: | |
# matrix: | |
# os: | |
# - ubuntu-latest | |
# - macos-latest | |
# - windows-latest | |
# python-version: | |
# - "3.8" | |
# - "3.9" | |
# - "3.10" | |
# - "3.11" | |
# - "3.12" | |
# - "3.13" | |
# runs-on: ${{ matrix.os }} | |
# continue-on-error: ${{ matrix.python-version == '3.13'}} | |
# 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: ${{ matrix.python-version }} | |
# allow-prereleases: true | |
# - name: Install Copier and uv | |
# run: pip install copier copier-templates-extensions uv | |
# - name: Test project generation and workflow | |
# run: bash tests/test_project.sh | |
test-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: Run project's own CI | |
env: | |
GH_TOKEN: ${{ secrets.TESTING_PUSH_TOKEN }} | |
run: | | |
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..." | |
make reset-history | |
cd tests/tmp || exit 1 | |
echo "Waiting project's workflow to complete..." | |
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}" | |
[ "${conclusion}" = "success" ] && break || exit 1 | |
else | |
echo "Workflow status: ${status}" | |
fi | |
else | |
echo "Workflow not started, retrying in 20 seconds" | |
fi | |
else | |
echo "Workflow not started, retrying in 20 seconds" | |
fi | |
sleep 20 | |
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 |