From c8cb89a690934ecd39ab42eccf41df53472903a1 Mon Sep 17 00:00:00 2001 From: dasm Date: Tue, 17 Jun 2025 15:47:15 -0700 Subject: [PATCH 1/2] Add a pipeline to push dev docs on each commit. --- .github/workflows/commit.yml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/commit.yml diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml new file mode 100644 index 00000000..a0bc0b01 --- /dev/null +++ b/.github/workflows/commit.yml @@ -0,0 +1,67 @@ +name: Commit Pipeline + +concurrency: docs-push + +on: + push: + branches: + - 'main' + +env: + POETRY_VIRTUALENVS_IN_PROJECT: "true" + # Force nox to produce colorful logs: + FORCE_COLOR: "true" + +jobs: + Package: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up runner + uses: ./.github/actions/setup + - run: poetry run nox -s build + - name: Archive packaged library + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist + + Push-Docs: + runs-on: ubuntu-latest + environment: docs-push + needs: Package + steps: + - name: Checkout code repository + uses: actions/checkout@v4 + - name: Set up runner + uses: ./.github/actions/setup + - name: Download dist + uses: actions/download-artifact@v4 + with: + name: dist + path: dist + - name: Get commit + id: commit + run: echo "COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + - run: poetry run nox -s docs + - run: rm -r public/.doctrees + - name: Checkout docs repository + uses: actions/checkout@v4 + with: + repository: 'opendp/tumult-docs' + token: ${{ secrets.DOCS_REPO_PAT}} + path: tumult-docs + - run: rm -r tumult-docs/docs/analytics/dev + - run: mv public tumult-docs/docs/analytics/dev + - name: commit to docs repo + working-directory: tumult-docs + env: + COMMIT: ${{ steps.commit.outputs.COMMIT}} + run: | + git config user.name "docs-bot" + git config user.email "87283505+opendp-dev@users.noreply.github.com" + git add docs/analytics/dev + git commit -m "[auto] Publish docs for dev ($COMMIT)" + git push + From 7f6d5b178335ab9128fc601374e624f7396cc389 Mon Sep 17 00:00:00 2001 From: dasm Date: Mon, 23 Jun 2025 16:30:24 -0700 Subject: [PATCH 2/2] Fix sphinx environment variables. --- doc/conf.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 07e8235b..6e0167de 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -22,21 +22,23 @@ ### Build information -ci_tag = os.getenv("CI_COMMIT_TAG") -ci_branch = os.getenv("CI_COMMIT_BRANCH") +pipeline_type = os.getenv("GITHUB_REF_TYPE") +ref_name = os.getenv("GITHUB_REF_NAME") # For non-prerelease tags, make the version "vX.Y" to match how we show it in # the version switcher and the docs URLs. Sphinx's nomenclature around versions # can be a bit confusing -- "version" means sort of the documentation version # (for us, the minor release), while "release" is the full version number of the # package on which the docs were built. -if ci_tag and "-" not in ci_tag: - release = ci_tag - version = "v" + ".".join(ci_tag.split(".")[:2]) +if pipeline_type and pipeline_type == "tag" and "-" not in ref_name: + release = ref_name + version = "v" + ".".join(ref_name.split(".")[:2]) else: - release = version = ci_tag or ci_branch or "HEAD" + release = version = ref_name or "HEAD" -commit_hash = os.getenv("CI_COMMIT_SHORT_SHA") or "unknown version" +commit_sha = os.getenv("GITHUB_SHA") + +commit_hash = commit_sha[:8] if commit_sha else "unknown version" build_time = datetime.datetime.utcnow().isoformat(sep=" ", timespec="minutes") # Linkcheck will complain that these anchors don't exist,