update #48
This file contains hidden or 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: verify | |
| on: push | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: verify-cache-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| verify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.14' | |
| - name: Install dependencies | |
| run: | | |
| pip3 install -U "setuptools<81" | |
| pip3 install -U online-judge-verify-helper | |
| - name: Restore verify cache | |
| run: | | |
| git fetch origin verify-cache || true | |
| if git show-ref --verify --quiet refs/remotes/origin/verify-cache; then | |
| git checkout origin/verify-cache -- .verify-helper/timestamps.local.json || true | |
| git checkout origin/verify-cache -- .verify-helper/timestamps.remote.json || true | |
| fi | |
| - name: Run tests | |
| env: | |
| YUKICODER_TOKEN: ${{ secrets.YUKICODER_TOKEN }} | |
| run: oj-verify run --timeout=3600 | |
| - name: Save verify cache | |
| if: always() | |
| run: | | |
| mkdir -p /tmp/verify-cache-files/.verify-helper | |
| found=0 | |
| for file in .verify-helper/timestamps.local.json .verify-helper/timestamps.remote.json; do | |
| if [ -f "$file" ]; then | |
| cp "$file" /tmp/verify-cache-files/.verify-helper/ | |
| found=1 | |
| fi | |
| done | |
| if [ "$found" -eq 0 ]; then | |
| echo "No verify timestamp files found." | |
| exit 0 | |
| fi | |
| git worktree add /tmp/verify-cache-worktree HEAD | |
| cd /tmp/verify-cache-worktree | |
| git switch --orphan verify-cache | |
| git rm -rf . || true | |
| mkdir -p .verify-helper | |
| cp /tmp/verify-cache-files/.verify-helper/*.json .verify-helper/ | |
| git config user.name "GitHub" | |
| git config user.email "noreply@github.com" | |
| git add .verify-helper | |
| git commit -m "Update verify cache" || exit 0 | |
| git push --force origin HEAD:verify-cache | |
| - name: Generate docs with Library Checker coverage | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| env: | |
| REPO_LINK_PREFIX: https://github.com/${{ github.repository }}/blob/${{ github.sha }}/ | |
| run: | | |
| oj-verify docs | |
| python3 tools/library_checker_coverage.py --refresh --mode all --format page --link-prefix "$REPO_LINK_PREFIX" --update-pages-index .verify-helper/markdown/index.md > .verify-helper/markdown/library-checker-coverage.md | |
| - name: Set up Ruby for docs | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3' | |
| bundler-cache: true | |
| working-directory: .verify-helper/markdown | |
| - name: Configure Pages | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| id: pages | |
| uses: actions/configure-pages@v5 | |
| - name: Build docs site | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| env: | |
| PAGES_REPO_NWO: ${{ github.repository }} | |
| PAGES_ORIGIN: ${{ steps.pages.outputs.origin }} | |
| PAGES_BASE_PATH: ${{ steps.pages.outputs.base_path }} | |
| run: | | |
| cd .verify-helper/markdown | |
| printf 'url: "%s"\nbaseurl: "%s"\n' "$PAGES_ORIGIN" "$PAGES_BASE_PATH" > _config_pages.yml | |
| bundle exec jekyll build --config _config.yml,_config_pages.yml | |
| - name: Publish docs | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| personal_token: ${{ secrets.GH_PAT }} | |
| publish_dir: ./.verify-helper/markdown/_site | |
| force_orphan: true | |
| coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.14' | |
| - name: Generate Library Checker coverage | |
| env: | |
| REPO_LINK_PREFIX: https://github.com/${{ github.repository }}/blob/${{ github.sha }}/ | |
| run: | | |
| python3 tools/library_checker_coverage.py --refresh --mode all --format json > library-checker-coverage.json | |
| python3 tools/library_checker_coverage.py --mode all --format csv > library-checker-coverage.csv | |
| python3 tools/library_checker_coverage.py --mode all --format markdown --link-prefix "$REPO_LINK_PREFIX" > library-checker-coverage.md | |
| BEFORE="${{ github.event.before }}" | |
| if [ "$BEFORE" != "0000000000000000000000000000000000000000" ] && git cat-file -e "$BEFORE^{commit}"; then | |
| git worktree add /tmp/library-checker-coverage-base "$BEFORE" | |
| python3 tools/library_checker_coverage.py --root /tmp/library-checker-coverage-base --mode all --format json > library-checker-coverage.previous.json | |
| set +e | |
| python3 tools/library_checker_coverage.py --mode all --format summary --compare-json library-checker-coverage.previous.json --fail-on-decrease --link-prefix "$REPO_LINK_PREFIX" > library-checker-coverage-summary.md | |
| COVERAGE_STATUS=$? | |
| set -e | |
| else | |
| echo "[]" > library-checker-coverage.previous.json | |
| python3 tools/library_checker_coverage.py --mode all --format summary --link-prefix "$REPO_LINK_PREFIX" > library-checker-coverage-summary.md | |
| COVERAGE_STATUS=0 | |
| fi | |
| cat library-checker-coverage-summary.md >> "$GITHUB_STEP_SUMMARY" | |
| exit "$COVERAGE_STATUS" | |
| - name: Upload Library Checker coverage | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: library-checker-coverage | |
| path: | | |
| library-checker-coverage.md | |
| library-checker-coverage-summary.md | |
| library-checker-coverage.json | |
| library-checker-coverage.previous.json | |
| library-checker-coverage.csv |