-
Notifications
You must be signed in to change notification settings - Fork 4
infra: docs-as-code setup #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f039903
4a7ed83
3c3595b
c2fb8e3
6c3baaa
c2989e8
d48ed40
b8726e0
4fef308
3fcabaf
b8d5557
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ | ||
| common --registry=https://bcr.bazel.build | ||
|
|
||
| build --java_language_version=17 | ||
| build --tool_java_language_version=17 | ||
| build --java_runtime_version=remotejdk_17 | ||
| build --tool_java_runtime_version=remotejdk_17 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 8.6.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # 👋 Code owners help maintain this repository and keep it aligned with our technical vision. | ||
| # You're responsible for reviewing changes, ensuring quality, and guiding contributors. | ||
| # You're also encouraged to help triage issues and keep discussions constructive and focused. | ||
| # Ownership can be shared, delegated, or updated as the project evolves. | ||
|
|
||
| # For more information about CODEOWNERS, see: | ||
| # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners | ||
|
|
||
|
|
||
| # This repository is maintained by the following individuals, who are responsible for reviewing and approving changes to the codebase: | ||
| # * @AlexanderLanin @MaximilianSoerenPollak | ||
|
|
||
| # However as this would create a potential bottleneck, we also want to cast a wider net and encourage the following individuals to also review and approve changes to the codebase. | ||
|
|
||
| # PLEASE LEAVE CRITICAL DECISIONS TO THE FIRST GROUP, BUT FEEL FREE TO APPROVE ANYTHING ELSE. | ||
|
|
||
| # Note: this does in no way mean that the first group is in any way more important! | ||
| # It's just the usual maintainer assignment that we perform per repository. | ||
| # It will be updated as the repository evolves, based on real life experience on who is actively maintaining (not contributing to!!) the repository. | ||
|
|
||
| * @AlexanderLanin @MaximilianSoerenPollak @dcalavrezo-qorix @pawelrutkaq @PiotrKorkus @lurtz @nradakovic @opajonk @antonkri @FScholPer @anmittag | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| name: Publish Documentation | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["PR"] | ||
| types: | ||
| - completed | ||
|
|
||
| concurrency: | ||
| group: pages-deploy | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| docs-deploy: | ||
| name: Deploy documentation to GitHub Pages | ||
| if: github.event.workflow_run.conclusion == 'success' | ||
| permissions: | ||
| actions: read | ||
| pages: write | ||
| id-token: write | ||
| contents: write | ||
| pull-requests: write | ||
|
AlexanderLanin marked this conversation as resolved.
|
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Download build metadata | ||
| uses: actions/download-artifact@v8.0.1 | ||
| with: | ||
| name: build-metadata | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ github.token }} | ||
|
|
||
| - name: Parse build metadata | ||
| id: metadata | ||
| run: | | ||
| EVENT_NAME=$(jq -r '.event_name' build-info.json) | ||
| PR_NUMBER=$(jq -r '.pr_number // empty' build-info.json) | ||
| REF_NAME=$(jq -r '.ref_name' build-info.json) | ||
|
|
||
| case "$EVENT_NAME" in | ||
| pull_request|push|merge_group|release) ;; | ||
| *) | ||
| echo "::error::Unexpected event_name: $EVENT_NAME" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| if [[ -n "$PR_NUMBER" && ! "$PR_NUMBER" =~ ^[0-9]+$ ]]; then | ||
| echo "::error::Invalid pr_number: $PR_NUMBER" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! "$REF_NAME" =~ ^[a-zA-Z0-9._/-]+$ ]]; then | ||
| echo "::error::Invalid ref_name: $REF_NAME" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$EVENT_NAME" == "merge_group" ]]; then | ||
| echo "should_deploy=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "should_deploy=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| echo "event_name=$EVENT_NAME" >> "$GITHUB_OUTPUT" | ||
| echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" | ||
| echo "ref_name=$REF_NAME" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Determine target folder | ||
| if: steps.metadata.outputs.should_deploy == 'true' | ||
| id: target | ||
| run: | | ||
| EVENT_NAME="${{ steps.metadata.outputs.event_name }}" | ||
| if [[ "$EVENT_NAME" == "pull_request" ]]; then | ||
| echo "folder=pr-${{ steps.metadata.outputs.pr_number }}" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "folder=${{ steps.metadata.outputs.ref_name }}" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Checkout gh-pages | ||
| if: steps.metadata.outputs.should_deploy == 'true' | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: gh-pages | ||
| path: gh-pages-content | ||
|
|
||
| - name: Clean up old documentation | ||
| if: steps.metadata.outputs.should_deploy == 'true' | ||
| run: | | ||
| rm -rf "gh-pages-content/${{ steps.target.outputs.folder }}" | ||
|
|
||
| - name: Download documentation artifact | ||
| uses: actions/download-artifact@v8.0.1 | ||
| with: | ||
| name: github-pages | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ github.token }} | ||
| path: gh-pages-content/${{ steps.target.outputs.folder }} | ||
|
|
||
| - name: Ensure .nojekyll exists | ||
| if: steps.metadata.outputs.should_deploy == 'true' | ||
| run: touch gh-pages-content/.nojekyll | ||
|
|
||
| - name: Extend versions.json | ||
| if: steps.metadata.outputs.should_deploy == 'true' | ||
| run: | | ||
| TARGET="${{ steps.target.outputs.folder }}" | ||
|
|
||
| # if versions.json does not exist, create it with an empty array as content | ||
| if [ ! -f gh-pages-content/versions.json ]; then | ||
| echo '[]' > gh-pages-content/versions.json | ||
| fi | ||
|
|
||
| # Add new version entry to versions.json if it doesn't already exist | ||
| if jq -e --arg v "$TARGET" 'map(select(.version == $v)) | length > 0' gh-pages-content/versions.json > /dev/null; then | ||
|
AlexanderLanin marked this conversation as resolved.
|
||
| echo "Version '$TARGET' already exists in versions.json" | ||
| else | ||
| REPO_NAME=$(basename "${{ github.repository }}") | ||
| OWNER_NAME="${{ github.repository_owner }}" | ||
| PAGES_URL="https://${OWNER_NAME}.github.io/${REPO_NAME}" | ||
| jq --arg v "$TARGET" --arg u "${PAGES_URL}/${TARGET}/" \ | ||
| '. + [{"version": $v, "url": $u}]' gh-pages-content/versions.json > gh-pages-content/tmp.json && mv gh-pages-content/tmp.json gh-pages-content/versions.json | ||
|
AlexanderLanin marked this conversation as resolved.
|
||
| fi | ||
|
|
||
| - name: Commit and push changes to gh-pages | ||
| if: steps.metadata.outputs.should_deploy == 'true' | ||
| run: | | ||
| cd gh-pages-content | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
AlexanderLanin marked this conversation as resolved.
|
||
| git add . | ||
| git commit -m "Update documentation for ${{ steps.target.outputs.folder }}" || echo "No changes to commit" | ||
| git push | ||
|
|
||
| - name: Create artifact from gh-pages | ||
| if: steps.metadata.outputs.should_deploy == 'true' | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: gh-pages-content | ||
|
|
||
| - name: Deploy artifact to GitHub Pages | ||
| if: steps.metadata.outputs.should_deploy == 'true' | ||
| id: deploy-pages | ||
| uses: actions/deploy-pages@v4 | ||
|
|
||
| - name: Find existing PR comment | ||
| if: steps.metadata.outputs.should_deploy == 'true' && steps.metadata.outputs.event_name == 'pull_request' && steps.metadata.outputs.pr_number != '' | ||
| uses: peter-evans/find-comment@v3 | ||
| id: fc | ||
| with: | ||
| issue-number: ${{ steps.metadata.outputs.pr_number }} | ||
| comment-author: 'github-actions[bot]' | ||
| body-includes: Documentation preview for this pull request | ||
|
|
||
| - name: Comment on PR with preview link | ||
| if: steps.metadata.outputs.should_deploy == 'true' && steps.metadata.outputs.event_name == 'pull_request' && steps.metadata.outputs.pr_number != '' && steps.fc.outputs.comment-id == '' | ||
|
AlexanderLanin marked this conversation as resolved.
|
||
| uses: peter-evans/create-or-update-comment@v4 | ||
| with: | ||
| issue-number: ${{ steps.metadata.outputs.pr_number }} | ||
| body: | | ||
| Documentation preview for this pull request is available at: | ||
| **${{ steps.target.outputs.folder }}**: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ steps.target.outputs.folder }}/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| name: PR | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize] | ||
| push: | ||
| branches: | ||
| - main # docs are built only on push to main branch, for feature branches there are PR builds | ||
| merge_group: | ||
| types: [checks_requested] | ||
| release: | ||
| types: [created] | ||
|
|
||
| jobs: | ||
| docs-build: | ||
| name: Build documentation | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: eclipse-score/more-disk-space@v1 | ||
|
|
||
| - name: Check out | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Build documentation | ||
| run: | | ||
| bazel run //:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should enable --lockfile_mode=error here too no, to be consitent with the rest of S-Core?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docs should not fail because of lockfiles. Lockfiles should fail because of lockfiles 🔒 But since we dont have proper "buy-in" on https://github.com/eclipse-score/cicd-workflows/blob/main/.github/workflows/on-pr.yml I have excluded it for now. |
||
|
|
||
| - name: Upload documentation artifact | ||
| uses: actions/upload-artifact@v7.0.1 | ||
| with: | ||
|
AlexanderLanin marked this conversation as resolved.
|
||
| name: github-pages | ||
| path: _build | ||
| retention-days: 1 | ||
| if-no-files-found: error | ||
|
|
||
| - name: Create build metadata | ||
| run: | | ||
| cat > build-info.json <<'EOF' | ||
| { | ||
| "event_name": "${{ github.event_name }}", | ||
| "pr_number": "${{ github.event.pull_request.number }}", | ||
| "ref_name": "${{ github.ref_name }}", | ||
| "head_sha": "${{ github.sha }}" | ||
| } | ||
| EOF | ||
|
|
||
| - name: Upload build metadata | ||
| uses: actions/upload-artifact@v7.0.1 | ||
| with: | ||
| name: build-metadata | ||
| path: build-info.json | ||
| retention-days: 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Bazel | ||
| bazel-* | ||
|
|
||
| # Docs | ||
| /.venv* | ||
| /_build* | ||
| docs/ubproject.toml | ||
|
|
||
| # AI | ||
| /.claude | ||
| /.codex |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| load("@score_docs_as_code//:docs.bzl", "docs") | ||
|
|
||
| docs(source_dir = "docs") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| module(name = "score_infrastructure") | ||
|
|
||
| ############################################################################### | ||
| # | ||
| # Python version | ||
| # | ||
| ############################################################################### | ||
| bazel_dep(name = "rules_python", version = "1.8.3") | ||
|
|
||
| PYTHON_VERSION = "3.12" | ||
|
|
||
| python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True) | ||
| python.toolchain( | ||
| configure_coverage_tool = True, | ||
| is_default = True, | ||
| python_version = PYTHON_VERSION, | ||
| ) | ||
| use_repo(python) | ||
|
|
||
| ############################################################################### | ||
| # | ||
| # Documentation | ||
| # | ||
| ############################################################################### | ||
| bazel_dep(name = "score_docs_as_code", version = "4.1.0") | ||
|
MaximilianSoerenPollak marked this conversation as resolved.
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for now this makes sense.
Might be good for future itterations to have certain people review changes in certain folders that pretend to them.
Like infra for us, or testing for piotr etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont want a setup like in score, where it is plain impossible to land a cross topic PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true.
Though I mean here it would make almost more sense cause it strictly is 'just' documentation.
But ye i agree it makes sense to keep it like this for now.