Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/actions/sphinx/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ inputs:
required: false
default: scaleway
BUCKET:
required: false
default: prod-probabl-skore
required: true
SOURCE:
required: true
DESTINATION:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
python -m pytest -n auto --junitxml=coverage/coverage.xml --cov=skore src/ tests/ | tee coverage/coverage.txt

- name: Upload coverage reports
if: ${{ matrix.coverage }}
if: ${{ matrix.coverage && (github.event_name == 'pull_request') }}
uses: actions/upload-artifact@v4
with:
name: backend-coverage
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
npm run test:unit:coverage

- name: Upload coverage reports
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: frontend-coverage
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/pr-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: cleanup PR

on:
pull_request_target:
types: [closed]

permissions: {}

defaults:
run:
shell: "bash"

jobs:
clean-artifacts:
if: always()
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Clean artifacts
run: |
set -u

ARTIFACTS=$( \
gh api \
--paginate \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/probabl-ai/skore/actions/artifacts \
| \
jq -c " \
.artifacts[] \
| select((.workflow_run.head_branch == \"${HEAD_BRANCH}\") and (.workflow_run.head_repository_id == ${HEAD_REPOSITORY_ID})) \
| {id: .id, name: .name} \
" \
)

for ARTIFACT in $ARTIFACTS; do
ID=$(echo "${ARTIFACT}" | jq -r '.id')
NAME=$(echo "${ARTIFACT}" | jq -r '.name')

echo "Deleting artifact (NAME: \"${NAME}\", ID: \"${ID}\")"

gh api \
--method DELETE \
--silent \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${REPOSITORY_OWNER}/${REPOSITORY_NAME}/actions/artifacts/${ID}
done
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY_OWNER: ${{ github.repository_owner }}
REPOSITORY_NAME: ${{ github.event.repository.name }}
HEAD_REPOSITORY_ID: ${{ github.event.pull_request.head.repo.id }}
HEAD_BRANCH: ${{ github.head_ref }}

clean-documentation-preview:
if: always()
runs-on: ubuntu-latest
steps:
- name: Install `rclone`
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y rclone

- name: Copy configuration
shell: bash
run: echo "${CONFIGURATION}" > rclone.configuration
env:
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOC_PREVIEW }}

- name: Clean documentation preview
run: rclone --config rclone.configuration purge "${PROVIDER}:${BUCKET}/${PULL_REQUEST_NUMBER}"
env:
PROVIDER: scaleway
BUCKET: ${{ vars.DOCUMENTATION_PREVIEW_BUCKET }}
PULL_REQUEST_NUMBER: ${{ github.event.number }}
71 changes: 71 additions & 0 deletions .github/workflows/pr-serve-documentation-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: serve documentation preview in PR

on:
workflow_run:
workflows: [sphinx]
types: [completed]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
acquire-pr-context:
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
PR_NUMBER: ${{ steps.acquire-pr-context.outputs.number }}
PR_HEADSHA: ${{ steps.acquire-pr-context.outputs.headsha }}
permissions:
contents: read
steps:
- id: acquire-pr-context
run: gh pr view --repo "${REPOSITORY}" "${BRANCH}" --json 'number,headRefOid' --jq '"number=\(.number)\nheadsha=\(.headRefOid)"' >> "${GITHUB_OUTPUT}"
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
BRANCH: |-
${{
(github.event.workflow_run.head_repository.fork == true)
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
|| github.event.workflow_run.head_branch
}}

serve-documentation-preview:
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
needs: [acquire-pr-context]
permissions:
actions: read
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download HTML artifacts
uses: actions/download-artifact@v4
with:
name: sphinx-html-artifact
path: html/
github-token: ${{ github.token }}
run-id: ${{ github.event.workflow_run.id }}

- name: Serve documentation preview
uses: ./.github/actions/sphinx/deploy
with:
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOC_PREVIEW }}
BUCKET: ${{ vars.DOCUMENTATION_PREVIEW_BUCKET }}
SOURCE: html/
DESTINATION: ${{ needs.acquire-pr-context.outputs.PR_NUMBER }}/

- name: Comment with documentation preview link
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ needs.acquire-pr-context.outputs.PR_NUMBER }}
header: documentation-preview
message: >-
[Documentation preview](${{ vars.DOCUMENTATION_PREVIEW_URL }}/${{ needs.acquire-pr-context.outputs.PR_NUMBER }})
@ ${{ needs.acquire-pr-context.outputs.PR_HEADSHA }}
13 changes: 8 additions & 5 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ jobs:
path: sphinx/build/html/

sphinx-deploy-html:
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
runs-on: ubuntu-latest
needs: [sphinx-version, sphinx-build]
steps:
- uses: actions/checkout@v4
Expand All @@ -128,12 +128,13 @@ jobs:
- uses: ./.github/actions/sphinx/deploy
with:
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOCS }}
BUCKET: ${{ vars.DOCUMENTATION_BUCKET }}
SOURCE: html/
DESTINATION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}/

sphinx-deploy-root-files:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
needs: [sphinx-version, sphinx-build, sphinx-deploy-html]
steps:
- uses: actions/checkout@v4
Expand All @@ -144,7 +145,7 @@ jobs:
import operator
import json

url = "https://skore.probabl.ai"
url = os.environ["URL"]
current = os.environ["CURRENT"]

response = requests.get(f"{url}/versions.json")
Expand Down Expand Up @@ -177,17 +178,19 @@ jobs:
"""
)
env:
URL: ${{ vars.DOCUMENTATION_URL }}
CURRENT: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}
- uses: ./.github/actions/sphinx/deploy
with:
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOCS }}
BUCKET: ${{ vars.DOCUMENTATION_BUCKET }}
ACTION: copy
SOURCE: artifacts/
DESTINATION:

sphinx-clean:
sphinx-clean-artifacts:
runs-on: ubuntu-latest
if: always()
if: ${{ always() && (github.event_name != 'pull_request') }}
needs: [sphinx-version, sphinx-build, sphinx-deploy-html, sphinx-deploy-root-files]
steps:
- uses: geekyeggo/delete-artifact@v5
Expand Down
Loading