From bb62d91b77fff52b52fa71221e3ff5c5a3f44b13 Mon Sep 17 00:00:00 2001 From: Anne Chew Date: Tue, 9 Dec 2025 14:40:31 +0800 Subject: [PATCH] docs: fix workflows Signed-off-by: Anne Chew --- .github/workflows/add-docs-link-comment.yml | 25 ------ .github/workflows/canonical-cla-check.yml | 10 --- .github/workflows/check-removed-urls.yml | 56 ++++++++++++ .github/workflows/cla-check.yml | 13 +++ .github/workflows/markdown-style-checks.yml | 11 ++- .github/workflows/release-docx.yml | 87 ------------------- .../sphinx-python-dependency-build-checks.yml | 51 +++++++++++ .github/workflows/verify-commit-signoff.yml | 45 ---------- 8 files changed, 127 insertions(+), 171 deletions(-) delete mode 100644 .github/workflows/add-docs-link-comment.yml delete mode 100644 .github/workflows/canonical-cla-check.yml create mode 100644 .github/workflows/check-removed-urls.yml create mode 100644 .github/workflows/cla-check.yml delete mode 100644 .github/workflows/release-docx.yml create mode 100644 .github/workflows/sphinx-python-dependency-build-checks.yml delete mode 100644 .github/workflows/verify-commit-signoff.yml diff --git a/.github/workflows/add-docs-link-comment.yml b/.github/workflows/add-docs-link-comment.yml deleted file mode 100644 index 414b00d..0000000 --- a/.github/workflows/add-docs-link-comment.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Comment link to ReadTheDocs build - -on: - pull_request: - types: - - opened - -jobs: - comment: - runs-on: ubuntu-latest - steps: - - name: Add PR comment with doc link - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const prNumber = context.payload.pull_request.number; - const commentBody = `Link to docs build: https://canonical-kernel-docs--${prNumber}.com.readthedocs.build/en/${prNumber}/`; - - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - body: commentBody - }); diff --git a/.github/workflows/canonical-cla-check.yml b/.github/workflows/canonical-cla-check.yml deleted file mode 100644 index 1f1e885..0000000 --- a/.github/workflows/canonical-cla-check.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: Canonical CLA check -on: [pull_request_target] - -jobs: - check-for-cla: - name: Check if author has signed the Canonical CLA. - runs-on: ubuntu-latest - steps: - - name: Check if CLA signed. - uses: canonical/has-signed-canonical-cla@main \ No newline at end of file diff --git a/.github/workflows/check-removed-urls.yml b/.github/workflows/check-removed-urls.yml new file mode 100644 index 0000000..a232637 --- /dev/null +++ b/.github/workflows/check-removed-urls.yml @@ -0,0 +1,56 @@ +name: Check for removed URLs + +on: + pull_request: + branches: [main] + +jobs: + build-docs: + runs-on: ubuntu-latest + steps: + - name: Checkout PR branch + uses: actions/checkout@v5 + with: + # This implicitly gets the PR branch. Making it explicit causes problems + # with private forks, but it is equivalent to the following: + # repository: ${{ github.event.pull_request.head.repo.full_name }} + # ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: 0 + path: compare + - name: Checkout base branch + uses: actions/checkout@v5 + with: + ref: ${{ github.event.pull_request.base.ref }} + repository: ${{ github.event.pull_request.base.repo.full_name }} + fetch-depth: 0 + path: base + - uses: actions/setup-python@v6 + - name: Build docs + run: | + for dir in compare base; do + pushd ${dir}/docs + make install + . .sphinx/venv/bin/activate + make html + popd + done + - name: Generate current URLs list + run: | + for dir in compare base; do + pushd ${dir}/docs + find ./_build/ -name '*.html' \ + | sed 's|/_build||;s|/index.html$|/|;s|.html$||' \ + | sort > urls.txt + popd + done + - name: Compare URLs + run: | + BASE_URLS_PATH="base/docs/urls.txt" + COMPARE_URLS_PATH="compare/docs/urls.txt" + removed=$(comm -23 ${BASE_URLS_PATH} ${COMPARE_URLS_PATH} ) + if [ -n "$removed" ]; then + echo "The following URLs were removed:" + echo "$removed" + echo "Please ensure removed pages are redirected" + exit 1 + fi diff --git a/.github/workflows/cla-check.yml b/.github/workflows/cla-check.yml new file mode 100644 index 0000000..56b465c --- /dev/null +++ b/.github/workflows/cla-check.yml @@ -0,0 +1,13 @@ +# This workflow checks if the contributor has signed the Canonical Contributor Licence Agreement (CLA) +name: Canonical Contributor Licence Agreement check + +on: + pull_request: + branches: [main] + +jobs: + cla-check: + runs-on: ubuntu-latest + steps: + - name: Check if CLA signed + uses: canonical/has-signed-canonical-cla@v2 diff --git a/.github/workflows/markdown-style-checks.yml b/.github/workflows/markdown-style-checks.yml index e0de019..883a8c1 100644 --- a/.github/workflows/markdown-style-checks.yml +++ b/.github/workflows/markdown-style-checks.yml @@ -16,9 +16,12 @@ jobs: markdown-lint: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - - uses: DavidAnson/markdownlint-cli2-action@v16 - with: - config: "docs/.sphinx/.markdownlint.json" + - name: Create venv + working-directory: "docs" + run: make install + - name: Lint markdown + working-directory: "docs" + run: make lint-md diff --git a/.github/workflows/release-docx.yml b/.github/workflows/release-docx.yml deleted file mode 100644 index 13a0d27..0000000 --- a/.github/workflows/release-docx.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Create docx files release -on: - push: - branches: ['main'] - # Add as many file paths as needed, each triggering the workflow when modified - paths: - - 'docs/how-to/build-publish/build-kernel.md' - - 'docs/how-to/build-publish/build-kernel-snap.md' - - 'docs/scripts/*' -jobs: - createDocxRelease: - runs-on: ubuntu-22.04 - steps: - - name: Check out documentation repository. - uses: actions/checkout@v4 - - name: Generate HTML and convert to DOCX. - working-directory: docs - run: make html-docx - - name: Get current date and time to be used as new tag. - id: get_date_time - run: | - RELEASE_TAG="v$(date -u +'%Y.%m.%d-%H.%M')" - echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV - - name: Create a new tag. - uses: actions/github-script@v7 - with: - script: | - github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: 'refs/tags/${{ env.RELEASE_TAG }}', - sha: context.sha - }) - # Create a new release that is associated with the tag created in the - # previous step. - - name: Create a tagged release. - id: create_release - uses: actions/github-script@v7 - with: - script: | - const response = await github.rest.repos.createRelease({ - owner: context.repo.owner, - repo: context.repo.repo, - tag_name: "${{ env.RELEASE_TAG }}", - name: "${{ env.RELEASE_TAG }}", - body: "${{ env.RELEASE_TAG }}", - draft: false, - prerelease: false - }); - console.log(response.data); - core.exportVariable('RELEASE_ID', response.data.id.toString()); - core.exportVariable('UPLOAD_URL', response.data.upload_url); - - name: Display Release ID and Upload URL - run: | - echo "Release ID: ${{ env.RELEASE_ID }}" - echo "Upload URL: ${{ env.UPLOAD_URL }}" - - name: Upload release asset (docx files). - id: upload_release_asset - uses: actions/github-script@v7 - with: - script: | - const fs = require('fs'); - const path = require('path'); - - // Specify the directory containing the DOCX files to upload - const directory = './docs/_build/docx/'; - const files = fs.readdirSync(directory); - - for (const file of files) { - if (path.extname(file) === '.docx') { // Adjust this if need to include other file types - const filePath = path.join(directory, file); - const fileContent = fs.readFileSync(filePath); - - console.log(`Uploading ${file}...`); - github.rest.repos.uploadReleaseAsset({ - owner: context.repo.owner, - repo: context.repo.repo, - release_id: "${{ env.RELEASE_ID }}", - name: file, - data: fileContent, - headers: { - 'content-type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'content-length': fileContent.length - } - }); - } - } diff --git a/.github/workflows/sphinx-python-dependency-build-checks.yml b/.github/workflows/sphinx-python-dependency-build-checks.yml new file mode 100644 index 0000000..0b8d48a --- /dev/null +++ b/.github/workflows/sphinx-python-dependency-build-checks.yml @@ -0,0 +1,51 @@ +# The purpose of this workflow file is to confirm that the Sphinx +# virtual environment can be built from source, consequently documenting +# the packages required in the build environment to do that. +# +# This is needed because some projects embeds the documentation into built +# artifacts which involves rendering the documentation on the target +# architecture. +# +# Depending on the architecture, pip may or may not have already built wheels +# available, and as such we need to make sure building wheels from source can +# succeed. +name: Sphinx python dependency build checks + +on: + push: + branches: [ main ] + pull_request: + workflow_dispatch: # manual trigger + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Install dependencies + run: | + set -ex + sudo apt-get --fix-missing update + sudo apt-get -y install \ + cargo \ + libpython3-dev \ + libxml2-dev \ + libxslt1-dev \ + make \ + python3-venv \ + rustc \ + libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev + - name: Build Sphinx venv + working-directory: "docs" + run: | + set -ex + make install \ + PIPOPTS="--no-binary :all:" \ + || ( cat .sphinx/venv/pip_install.log && exit 1 ) diff --git a/.github/workflows/verify-commit-signoff.yml b/.github/workflows/verify-commit-signoff.yml deleted file mode 100644 index 84e130a..0000000 --- a/.github/workflows/verify-commit-signoff.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Verify Commit Signoff - -on: - push: - branches: - - main - pull_request: - branches: - - '*' - workflow_dispatch: - -jobs: - verify-signoff: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Ensure full history is available - - - name: Validate commits - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Fetch full history for main branch - git fetch origin ${{ github.event.pull_request.base.ref }} --quiet - - # Determine the commit to verify: - # For pull requests, verify HEAD commit of the pull request branch - # For pushes (squash-merge), verify the latest commit in the branch - if [ "${{ github.event_name }}" = "pull_request" ]; then - TARGET_COMMIT=${{ github.event.pull_request.head.sha }} - else - TARGET_COMMIT=$(git rev-parse HEAD) - fi - - # Check the commit message for 'Signed-off-by:' - MESSAGE=$(git show -s --format='%B' $TARGET_COMMIT) - if ! echo "$MESSAGE" | grep -q "Signed-off-by:"; then - echo "❌ Commit $TARGET_COMMIT is missing a 'Signed-off-by:' line." - exit 1 - fi - - echo "✅ Commit $TARGET_COMMIT is properly signed off."