Skip to content

Commit

Permalink
[MAINT] Update circle-ci trigger-hosting (#4402)
Browse files Browse the repository at this point in the history
* [MAINT] Update trigger-hosting.yml

* redirect artifact

* [DATALAD] Recorded changes

* [DATALAD] Recorded changes

* [DATALAD] Recorded changes

* test triggering with  another workflow

* let us try hard coding

* dump context

* test via doc

* clean up

* try with head ref

* try redirect artifacts

* reuse branch

* try with action

* revert to pinging API

* Update .github/workflows/build-docs.yml

Co-authored-by: bthirion <bertrand.thirion@inria.fr>

---------

Co-authored-by: bthirion <bertrand.thirion@inria.fr>
  • Loading branch information
Remi-Gau and bthirion committed Apr 26, 2024
1 parent d2ddfb9 commit 76b482b
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 124 deletions.
9 changes: 7 additions & 2 deletions .circleci/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Hosting and deployment of development docs on CircleCI

The development docs are built using GitHub Actions. See [.github/workflows/README.md](/.github/workflows/README.md) for details.
The development docs are built using GitHub Actions.

CircleCI is used to download and host the artifacts from GitHub Actions from builds on pull requests and "main". It also runs the deploy job to deploy the development documentation when there is a merge on "main". These jobs are triggered by Github Actions using [trigger-hosting.yml](/.github/workflows/trigger-hosting.yml) after a successful doc build.
See [.github/workflows/README.md](/.github/workflows/README.md) for details.

CircleCI is used to download and host the artifacts from GitHub Actions from builds on pull requests and "main".
It also runs the deploy job to deploy the development documentation when there is a merge on "main".
These jobs are triggered by Github Actions
using [build-docs.yml](/.github/workflows/build-docs.yml) after a successful doc build.
35 changes: 10 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@

version: 2.1

# Parameters required to trigger the execution
# of the "host_docs" job
# Parameters required to trigger the execution of the "host_docs" job
parameters:
GITHUB_RUN_URL:
type: string
default: none
STATUS:
type: string
default: failure

jobs:
host_docs:
Expand All @@ -23,51 +19,41 @@ jobs:
GITHUB_ARTIFACT_URL: << pipeline.parameters.GITHUB_RUN_URL >>/doc.zip
steps:
- checkout
- run: bash build_tools/circle/download_documentation.sh
- run:
name: Download documentation
command: bash build_tools/circle/download_documentation.sh
- store_artifacts:
path: doc/_build/html/
destination: dev
# Persists the generated documentation, so that it
# can be attached and deployed in the "deploy" job
# Persists the generated documentation, so that it
# can be attached and deployed in the "deploy" job
- persist_to_workspace:
root: doc/_build
paths:
- html

deploy:
docker:
- image: circleci/python:3.9
environment:
STATUS: << pipeline.parameters.STATUS >>
- image: cimg/python:3.12
steps:
- add_ssh_keys:
fingerprints:
- 19:56:86:2d:c6:df:02:f2:87:0e:59:a1:eb:b7:65:77
- attach_workspace:
at: /tmp/_build
- run:
name: Check status
command: |
echo $STATUS
if [[ "$STATUS" == "success" ]]; then
echo "Doc build is successful. Deploying docs..."
else
echo "Failed to deploy because doc build status is 'failure'"
exit 1
fi
- run:
name: Fetch docs
command: |
set -e
set -x -e
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts;
if [ ! -d ~/nilearn.github.io ]; then
git clone git@github.com:nilearn/nilearn.github.io.git ~/nilearn.github.io --depth=1
git clone git@github.com:nilearn/nilearn.github.io.git ~/nilearn.github.io --depth=1
fi
- run:
name: Deploy dev docs
command: |
set -e;
set -x -e
if [ "${CIRCLE_BRANCH}" == "main" ]; then
git config --global user.email "circle@nilearn.com";
git config --global user.name "CircleCI";
Expand All @@ -88,7 +74,6 @@ jobs:
fi
workflows:
version: 2

host_and_deploy_doc:
when:
Expand Down
35 changes: 21 additions & 14 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# GitHub Actions Specification

## Skip CI

You can decide to skip CI at any time by including the tag "[skip ci]" in your commit message.
For more information, see: https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs

```bash
$ git commit -m "[skip ci] commit message"
```

## Automatically assign issue

### assign.yml
Expand Down Expand Up @@ -69,34 +78,32 @@ To run a full build and download all datasets, you would then combine both tags:
$ git commit -m "[full doc][force download] request full build"
```

#### Skip CI
#### Hosting of the docs

You can decide to skip documentation building and tests execution at any time by including the tag "[skip ci]" in your commit message.
For more information, see: https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs

```bash
$ git commit -m "[skip ci] commit message"
```

### trigger-hosting.yml

Runs only if the workflow in `build-docs.yml` completes successfully. Triggers the CircleCI job described below.
Upon a successful build of the doc, it is zipped and uploaded as an artifact.
A circle-ci workflow is then triggered. See below.

## Hosting and deploying development documentation

### [.circleci/config.yml](/.circleci/config.yml)

Artifacts hosting and deployment of development docs use CircleCI. See [.circleci/README.md](../../.circleci/README.md) for details.
On a pull request, only the "host" job is run. Then the artifacts can be accessed from the `host_and_deploy_doc` workflow seen under the checks list. Click on "Details" and then on the "host_docs" link on the page that opens. From there you can click on the artifacts tab to see all the html files. If you click on any of them you can then normally navigate the pages from there.
Artifacts hosting and deployment of development docs use CircleCI.
See [.circleci/README.md](../../.circleci/README.md) for details.
On a pull request, only the "host" job is run.
Then the artifacts can be accessed from the `host_and_deploy_doc` workflow seen under the checks list.
Click on "Details" and then on the "host_docs" link on the page that opens.
From there you can click on the artifacts tab to see all the html files.
If you click on any of them you can then normally navigate the pages from there.
With a merge on main, both "host" and "deploy" jobs are run.

## Check run time of test suite
## Check run time of CI

### check_gha_workflow.yml

Pings github API to collect information about:
- how long each run of the test suite lasted,
- how long the build of the doc lasted.

Plots the results and saves it as an artefact to download and manually inspect
to see if there is a trend in tests taking longer.

Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ jobs:
validate_cff:
# This prevents this workflow from running on a fork.
# To test this workflow on a fork, uncomment the following line.
if: github.repository == 'nilearn/nilearn'
runs-on: ubuntu-latest
steps:
- name: Checkout nilearn
Expand All @@ -59,7 +58,6 @@ jobs:
# To test this workflow on a fork, uncomment the following line.
if: github.repository == 'nilearn/nilearn'
runs-on: ubuntu-latest
timeout-minutes: 360
defaults:
run:
shell: bash -el {0}
Expand Down Expand Up @@ -170,9 +168,7 @@ jobs:
needs: [get_data, validate_cff]
# This prevents this workflow from running on a fork.
# To test this workflow on a fork, uncomment the following line.
if: github.repository == 'nilearn/nilearn'
runs-on: ubuntu-latest
timeout-minutes: 360
defaults:
run:
shell: bash -el {0}
Expand Down Expand Up @@ -238,10 +234,13 @@ jobs:
- name: Set up display server for virtual browser
run: Xvfb -ac :99 -screen 0 1280x1024x16 > /dev/null 2>&1 &

# Run the doc build. If no data is restored in previous steps, the data
# will be downloaded during the build (this only applies for full builds;
# Run the doc build.
# If no data is restored in previous steps,
# the data will be downloaded during the build
# (this only applies for full builds;
# no data is downloaded for partial builds).
- name: Build docs
id: build-docs
run: |
cd doc;
set -o pipefail;
Expand All @@ -252,8 +251,22 @@ jobs:
./build_tools/github/fill_doc_check.sh
cat doc/tmp/doc_check.txt
- name: Upload documentation
if: always()
if: steps.build-docs.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: doc
path: doc/_build/html

# Trigger hosting / deploy of the doc on nilearn.github.io via circle-ci
# We get the url for the artifacts for circle-ci from https://nightly.link/
- name: Trigger hosting jobs on circle ci
if: steps.build-docs.outcome == 'success'
run: |
GITHUB_RUN_URL="https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}"
curl --request POST \
--url https://circleci.com/api/v2/project/gh/${{ github.repository }}/pipeline \
--header "Circle-Token: ${{ secrets.CIRCLE_CI_TOKEN }}" \
--header "content-type: application/json" \
--header "x-attribution-actor-id: github_actions" \
--header "x-attribution-login: github_actions" \
--data \{\"branch\":\"${{ github.head_ref }}\",\"parameters\":\{\"GITHUB_RUN_URL\":\"$GITHUB_RUN_URL\"\}\}
10 changes: 8 additions & 2 deletions .github/workflows/circle_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
name: Redirect circleci artifacts
# Display a link to the artifacts at the bottom of a PR
# from https://github.com/marketplace/actions/run-circleci-artifacts-redirector
permissions: read-all
on: [status]
jobs:
circleci_artifacts_redirector_job:
runs-on: ubuntu-20.04
if: "${{ startsWith(github.event.context, 'ci/circleci: host_docs') }}"
runs-on: ubuntu-latest
name: Run CircleCI artifacts redirector
permissions:
statuses: write
steps:
- name: GitHub Action step
uses: larsoner/circleci-artifacts-redirector-action@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
api-token: ${{ secrets.CIRCLE_CI_TOKEN }}
artifact-path: 0/dev/index.html
circleci-jobs: build_docs
circleci-jobs: host_docs
job-title: Check the HTML doc here!
32 changes: 0 additions & 32 deletions .github/workflows/trigger-hosting.yml

This file was deleted.

3 changes: 1 addition & 2 deletions build_tools/circle/download_documentation.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

set -e
set -x
set -x -e

wget $GITHUB_ARTIFACT_URL
mkdir -p doc/_build/html
Expand Down
40 changes: 0 additions & 40 deletions build_tools/github/trigger_hosting.sh

This file was deleted.

0 comments on commit 76b482b

Please sign in to comment.