From 36b2792fe7dc60b0db130ed5f6a9d0f75310fea5 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 2 Aug 2020 08:04:45 -0700 Subject: [PATCH 1/2] Split docs workflow into validate and publish workflows The docs workflow had two uses: - Check that changes to docs don't break the static website build system - Publish the docs to the website To make the CI system friendly to contributors, it should be easy for them to validate documentation changes from a feature branch, meaning the validation aspect should run on a push to any branch. However, the special behavior of the workflow to publish on pushes conflicted with that usage. The most simple solution is to split the workflow into two. The validation workflow contains the process of interest to contributors, and is thus made friendly to their development process. The publishing workflow is not of interest to contributors, and thus doesn't need to be configured to run on pushes to any branch. --- .../{docs.yaml => publish-docs.yaml} | 25 +------ .github/workflows/validate-docs.yaml | 74 +++++++++++++++++++ 2 files changed, 77 insertions(+), 22 deletions(-) rename .github/workflows/{docs.yaml => publish-docs.yaml} (74%) create mode 100644 .github/workflows/validate-docs.yaml diff --git a/.github/workflows/docs.yaml b/.github/workflows/publish-docs.yaml similarity index 74% rename from .github/workflows/docs.yaml rename to .github/workflows/publish-docs.yaml index be7e254de89..97744f6ea4f 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -1,18 +1,6 @@ -name: docs +name: publish-docs on: - pull_request: - paths: - # existing docs - - "docs/**" - # changes to the cli reference generator - - "docsgen/**" - # potential changes to commands documentation - - "cli/**" - # potential changes to gRPC documentation - - "rpc/**" - # changes to the workflow itself - - ".github/workflows/docs.yaml" push: branches: - master @@ -24,10 +12,10 @@ on: - "docsgen/**" - "cli/**" - "rpc/**" - - ".github/workflows/docs.yaml" + - ".github/workflows/publish-docs.yaml" jobs: - build: + publish: runs-on: ubuntu-latest steps: @@ -73,17 +61,10 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r ./requirements_docs.txt - - name: Build docs website - # This runs on every PR to ensure the docs build is sane, these docs - # won't be published - if: github.event_name == 'pull_request' - run: task docs:build - - name: Publish docs # Determine docs version for the commit pushed and publish accordingly using Mike. # Publishing implies creating a git commit on the gh-pages branch, we let # ArduinoBot own these commits. - if: github.event_name == 'push' run: | git config --global user.email "bot@arduino.cc" git config --global user.name "ArduinoBot" diff --git a/.github/workflows/validate-docs.yaml b/.github/workflows/validate-docs.yaml new file mode 100644 index 00000000000..df2511b70f1 --- /dev/null +++ b/.github/workflows/validate-docs.yaml @@ -0,0 +1,74 @@ +name: validate-docs + +on: + pull_request: + paths: + # existing docs + - "docs/**" + # changes to the cli reference generator + - "docsgen/**" + # potential changes to commands documentation + - "cli/**" + # potential changes to gRPC documentation + - "rpc/**" + # changes to the workflow itself + - ".github/workflows/validate-docs.yaml" + push: + # At this day, GitHub doesn't support YAML anchors, d'oh! + paths: + - "docs/**" + - "docsgen/**" + - "cli/**" + - "rpc/**" + - ".github/workflows/validate-docs.yaml" + +jobs: + validate: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Taskfile + uses: Arduino/actions/setup-taskfile@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Go + uses: actions/setup-go@v2-beta + with: + go-version: "1.14" + + - name: Install Go dependencies + run: | + go version + go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc + + - name: Install protoc compiler + uses: arduino/setup-protoc@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: "3.6" + architecture: "x64" + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install Python dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r ./requirements_docs.txt + + - name: Build docs website + # Ensure the docs build is sane, these docs won't be published + run: task docs:build From 1839b8ecd2bd227ac24ea7de4f911e3dd6fcf22c Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 2 Aug 2020 08:10:56 -0700 Subject: [PATCH 2/2] Run workflows that are useful to contributors on push to any branch Contributors should run CI in their feature branch to make sure it's passing before submitting a PR. Previously, the CI workflows were configured to run only on push to the master branch, meaning that contributors would need to modify the workflows just to get them to run on a feature branch. It's very unlikely that a contributor would do that, so they are more likely to just submit the PR, then if CI on the PR fails push fixup commits until CI is passing. The solution is simply to remove the filters that caused the workflows to run only on push to master. --- .github/workflows/link-validation.yaml | 2 -- .github/workflows/python-lint.yaml | 2 -- .github/workflows/test.yaml | 2 -- 3 files changed, 6 deletions(-) diff --git a/.github/workflows/link-validation.yaml b/.github/workflows/link-validation.yaml index 08ae2e1acc5..f36037e68c2 100644 --- a/.github/workflows/link-validation.yaml +++ b/.github/workflows/link-validation.yaml @@ -2,8 +2,6 @@ name: Verifies documentation links on: push: - branches: - - master pull_request: schedule: - cron: "0 3 * * 1" # Every Monday at 03:00 diff --git a/.github/workflows/python-lint.yaml b/.github/workflows/python-lint.yaml index 14dc459486e..c736d875cd6 100644 --- a/.github/workflows/python-lint.yaml +++ b/.github/workflows/python-lint.yaml @@ -2,8 +2,6 @@ name: "Lints Python code" on: push: - branches: - - master paths: - "**.py" - ".flake8" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a5782720d7d..3b9e0f036da 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,8 +2,6 @@ name: test on: push: - branches: - - master pull_request: jobs: