Test Guides #367
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: Test Guides | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
schedule: | |
# run every week | |
# - cron: "0 0 * * 0" | |
# run every day | |
- cron: "0 1 * * *" | |
permissions: | |
contents: read | |
issues: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: ✅ Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: 🐍 Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Extract example branch name | |
id: extract_branch | |
shell: bash | |
run: | | |
echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
- name: Extract reference branch | |
id: check_branch | |
run: | | |
if git ls-remote --heads "https://github.com/CAREamics/careamics.git" ${{ steps.extract_branch.outputs.BRANCH }} | grep -q ${{ steps.extract_branch.outputs.BRANCH }}; then | |
echo "Branch ${{ steps.extract_branch.outputs.BRANCH }} exists in CAREamics." | |
CAREAMICS_BRANCH=${{ steps.extract_branch.outputs.BRANCH }} | |
else | |
echo "Branch ${{ steps.extract_branch.outputs.BRANCH }} does not exist. Defaulting to main." | |
CAREAMICS_BRANCH="main" | |
fi | |
echo "BRANCH=$CAREAMICS_BRANCH" >> $GITHUB_OUTPUT | |
- name: 📝 Write CAREamics branch to requirements.txt | |
uses: DamianReeves/[email protected] | |
with: | |
path: requirements.txt | |
contents: | | |
careamics @ git+https://github.com/CAREamics/careamics.git@${{ steps.check_branch.outputs.BRANCH }} | |
write-mode: append | |
- name: 📦 Install dependencies | |
run: pip install -r requirements.txt | |
- name: 📝 Run tests | |
run: pytest | |
# If something goes wrong, we can open an issue in the repo | |
- name: 📝 Report Failures | |
if: failure() && github.event_name == 'schedule' | |
uses: JasonEtco/create-an-issue@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RUN_ID: ${{ github.run_id }} | |
TITLE: "[test-bot] Guide examples are failing" | |
with: | |
filename: .github/workflows/TEST_FAIL_TEMPLATE.md | |
update_existing: true | |