|
| 1 | +name: VrForaging test suite |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - dev* |
| 10 | + - release* |
| 11 | + release: |
| 12 | + types: [published] |
| 13 | + |
| 14 | +jobs: |
| 15 | + # ╔──────────────────────────╗ |
| 16 | + # │ _____ _ │ |
| 17 | + # │ |_ _|__ ___| |_ ___ │ |
| 18 | + # │ | |/ _ \/ __| __/ __| │ |
| 19 | + # │ | | __/\__ \ |_\__ \ │ |
| 20 | + # │ |_|\___||___/\__|___/ │ |
| 21 | + # │ │ |
| 22 | + # ╚──────────────────────────╝ |
| 23 | + tests: |
| 24 | + runs-on: windows-latest |
| 25 | + name: VrForaging unit tests |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v5 |
| 28 | + |
| 29 | + - uses: astral-sh/setup-uv@v6 |
| 30 | + with: |
| 31 | + enable-cache: true |
| 32 | + |
| 33 | + - name: Install python dependencies |
| 34 | + run: uv sync |
| 35 | + |
| 36 | + - name: Run ruff format |
| 37 | + run: uv run ruff format |
| 38 | + |
| 39 | + - name: Run ruff check |
| 40 | + run: uv run ruff check |
| 41 | + |
| 42 | + - name: Run codespell |
| 43 | + run: uv run codespell |
| 44 | + |
| 45 | + - name: Setup .NET Core SDK |
| 46 | + uses: actions/setup-dotnet@v4 |
| 47 | + with: |
| 48 | + dotnet-version: 8.x |
| 49 | + |
| 50 | + - name: Restore dotnet tools |
| 51 | + run: dotnet tool restore |
| 52 | + |
| 53 | + - name: Setup Bonsai environment |
| 54 | + working-directory: ./bonsai |
| 55 | + run: ./setup.ps1 |
| 56 | + |
| 57 | + - name: Run python unit tests |
| 58 | + run: uv run python -m unittest |
| 59 | + |
| 60 | + - name: Regenerate schemas |
| 61 | + run: uv run vr-foraging regenerate |
| 62 | + |
| 63 | + - name: Check for uncommitted changes |
| 64 | + run: | |
| 65 | + git config --global core.safecrlf false |
| 66 | + git diff --exit-code || (echo "Untracked changes found" && exit 1) |
| 67 | +
|
| 68 | + # ╔───────────────────────────────────────────────────────────╗ |
| 69 | + # │ ____ ___ ____ ____ ____ _ │ |
| 70 | + # │ / ___|_ _/ ___| _ \ | _ \ ___| | ___ __ _ ___ ___ │ |
| 71 | + # │ | | | | | | | | | | |_) / _ \ |/ _ \/ _` / __|/ _ \ │ |
| 72 | + # │ | |___ | | |___| |_| | | _ < __/ | __/ (_| \__ \ __/ │ |
| 73 | + # │ \____|___\____|____/ |_| \_\___|_|\___|\__,_|___/\___| │ |
| 74 | + # │ │ |
| 75 | + # ╚───────────────────────────────────────────────────────────╝ |
| 76 | + github-rc-release: |
| 77 | + needs: tests |
| 78 | + runs-on: ubuntu-latest |
| 79 | + if: > |
| 80 | + github.ref == 'refs/heads/main' && |
| 81 | + github.event_name == 'push' && |
| 82 | + github.event.head_commit.author.email != 'github-actions[bot]@users.noreply.github.com' |
| 83 | + name: Create GitHub pre-release |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v5 |
| 86 | + with: |
| 87 | + fetch-depth: 0 |
| 88 | + ref: main |
| 89 | + |
| 90 | + - uses: astral-sh/setup-uv@v6 |
| 91 | + with: |
| 92 | + enable-cache: true |
| 93 | + |
| 94 | + - name: Bump pre-release by default |
| 95 | + run: uv version --bump rc |
| 96 | + |
| 97 | + - name: Regenerate schemas |
| 98 | + run: uv run vr-foraging regenerate |
| 99 | + |
| 100 | + - name: Commit version and schema changes |
| 101 | + run: | |
| 102 | + git config --global user.name "github-actions[bot]" |
| 103 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 104 | + git add . |
| 105 | + git commit -m "Bump version and regenerate schemas [skip ci]" || echo "No changes to commit" |
| 106 | + git push origin main |
| 107 | +
|
| 108 | + - name: Get version |
| 109 | + id: get_version |
| 110 | + run: | |
| 111 | + version=$(uv version --output-format json | jq -r '.version') |
| 112 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 113 | +
|
| 114 | + - name: Create GitHub Release |
| 115 | + uses: softprops/action-gh-release@v2 |
| 116 | + env: |
| 117 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + with: |
| 119 | + tag_name: v${{ steps.get_version.outputs.version }} |
| 120 | + name: v${{ steps.get_version.outputs.version }} |
| 121 | + generate_release_notes: true |
| 122 | + prerelease: true |
| 123 | + body: | |
| 124 | + Automated pre-release v${{ steps.get_version.outputs.version }} |
| 125 | +
|
| 126 | + # ╔─────────────────────────────────────────────────────────────────╗ |
| 127 | + # │ ____ _ _ _ ____ _ │ |
| 128 | + # │ | _ \ _ _| |__ | (_) ___ | _ \ ___| | ___ __ _ ___ ___ │ |
| 129 | + # │ | |_) | | | | '_ \| | |/ __| | |_) / _ \ |/ _ \/ _` / __|/ _ \ │ |
| 130 | + # │ | __/| |_| | |_) | | | (__ | _ < __/ | __/ (_| \__ \ __/ │ |
| 131 | + # │ |_| \__,_|_.__/|_|_|\___| |_| \_\___|_|\___|\__,_|___/\___| │ |
| 132 | + # │ │ |
| 133 | + # ╚─────────────────────────────────────────────────────────────────╝ |
| 134 | + |
| 135 | + github-public-release: |
| 136 | + runs-on: ubuntu-latest |
| 137 | + name: Create GitHub public release |
| 138 | + needs: tests |
| 139 | + if: github.event_name == 'release' && |
| 140 | + github.event.action == 'published' && |
| 141 | + !github.event.release.prerelease |
| 142 | + steps: |
| 143 | + - uses: actions/checkout@v5 |
| 144 | + with: |
| 145 | + fetch-depth: 0 |
| 146 | + ref: main |
| 147 | + |
| 148 | + - uses: astral-sh/setup-uv@v6 |
| 149 | + with: |
| 150 | + enable-cache: true |
| 151 | + |
| 152 | + - name: Get release version from tag |
| 153 | + id: get_version |
| 154 | + run: echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT |
| 155 | + |
| 156 | + - name: Validate version tag format |
| 157 | + run: uv version ${{ steps.get_version.outputs.version }} --dry-run |
| 158 | + |
| 159 | + - name: Update package version |
| 160 | + run: uv version ${{ steps.get_version.outputs.version }} |
| 161 | + |
| 162 | + - name: Regenerate schemas |
| 163 | + run: uv run vr-foraging regenerate |
| 164 | + |
| 165 | + - name: Commit version and schema changes |
| 166 | + run: | |
| 167 | + git config --global user.name "github-actions[bot]" |
| 168 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 169 | + git add . |
| 170 | + git commit -m "Set version and regenerate schemas" || echo "No changes to commit" |
| 171 | + git push origin main |
| 172 | +
|
| 173 | + # ╔─────────────────────────╗ |
| 174 | + # │ ____ │ |
| 175 | + # │ | _ \ ___ ___ ___ │ |
| 176 | + # │ | | | |/ _ \ / __/ __| │ |
| 177 | + # │ | |_| | (_) | (__\__ \ │ |
| 178 | + # │ |____/ \___/ \___|___/ │ |
| 179 | + # │ │ |
| 180 | + # ╚─────────────────────────╝ |
| 181 | + build-docs: |
| 182 | + name: Build and deploy documentation to GitHub Pages |
| 183 | + runs-on: ubuntu-latest |
| 184 | + needs: github-rc-release |
| 185 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 186 | + steps: |
| 187 | + - name: Checkout repository |
| 188 | + uses: actions/checkout@v5 |
| 189 | + |
| 190 | + - name: Install uv |
| 191 | + uses: astral-sh/setup-uv@v3 |
| 192 | + |
| 193 | + - name: Setup Graphviz |
| 194 | + uses: ts-graphviz/setup-graphviz@v2 |
| 195 | + |
| 196 | + - name: Install docs group of dependencies |
| 197 | + run: uv sync --group docs |
| 198 | + |
| 199 | + - name: Build Sphinx documentation |
| 200 | + run: uv run sphinx-build -b html docs/ _build/html |
| 201 | + |
| 202 | + - name: Deploy to GitHub Pages |
| 203 | + uses: peaceiris/actions-gh-pages@v4 |
| 204 | + with: |
| 205 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 206 | + publish_dir: _build/html |
| 207 | + force_orphan: true |
0 commit comments