Skip to content

ci-linux

ci-linux #17

Workflow file for this run

name: Self-Hosted CI
on:
workflow_dispatch:
inputs:
ref:
required: true
default: 'main'
targets:
required: true
default: '["rocm-7-0"]'
repository_dispatch:
types: [ci-linux]
env:
SOURCE_REPO_OWNER: 'cupy'
SOURCE_REPO_NAME: 'cupy'
jobs:
test:
runs-on: pg01-rocm
strategy:
matrix:
target: ${{
github.event_name == 'workflow_dispatch' && fromJSON(inputs.targets) || github.event.client_payload.targets
}}
env:
RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
RUN_TRIGGER: ${{
github.event_name == 'workflow_dispatch' && 'manual workflow dispatch' ||
format('{0}/{1}/{2}/pull/{3} ({4})',
github.server_url,
'cupy',
'cupy',
github.event.client_payload.pull_request,
github.event.client_payload.url
)
}}
RUN_TARGET: ${{ matrix.target }}
SOURCE_STATUS_REF: ${{
github.event_name == 'workflow_dispatch' && '' ||
github.event.client_payload.head_sha
}}
SOURCE_CHECKOUT_REF: ${{
github.event_name == 'workflow_dispatch' && inputs.ref ||
( github.event.client_payload.merge_commit_sha || github.event.client_payload.head_sha )
}}
steps:
- name: Information
uses: actions/github-script@v7
with:
script: |
core.notice(`Triggered by: ${ process.env.RUN_TRIGGER }`);
- name: Generate Token (Pre)
if: ${{ env.SOURCE_STATUS_REF != '' }}
id: generate-token-pre
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.GH_APP_SELF_HOSTED_CI_ID }}
private-key: ${{ secrets.GH_APP_SELF_HOSTED_CI_PEM }}
owner: ${{ env.SOURCE_REPO_OWNER }}
repositories: ${{ env.SOURCE_REPO_NAME }}
- name: Update Commit Status (Pre)
if: ${{ env.SOURCE_STATUS_REF != '' }}
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token-pre.outputs.token }}
script: |
await github.rest.repos.createCommitStatus({
owner: process.env.SOURCE_REPO_OWNER,
repo: process.env.SOURCE_REPO_NAME,
sha: process.env.SOURCE_STATUS_REF,
state: 'pending',
description: 'In progress',
target_url: process.env.RUN_URL,
context: process.env.RUN_TARGET,
})
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ env.SOURCE_REPO_OWNER }}/${{ env.SOURCE_REPO_NAME }}
ref: ${{ env.SOURCE_CHECKOUT_REF }}
submodules: recursive
- name: Build Docker Image
run: |
./.pfnci/linux/run.sh "${{ env.RUN_TARGET }}" build
- name: Test
id: test
env:
PULL_REQUEST: ${{ github.event_name == 'workflow_dispatch' && '' || github.event.client_payload.pull_request }}
CACHE_DIR: '/home/actions-runner/cache/cupy/self-hosted-ci'
run: |
./.pfnci/linux/run.sh "${{ env.RUN_TARGET }}" test
# Regenerate the token as the installation token expires in an hour.
- name: Generate Token (Post)
if: ${{ always() && env.SOURCE_STATUS_REF != '' }}
id: generate-token-post
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.GH_APP_SELF_HOSTED_CI_ID }}
private-key: ${{ secrets.GH_APP_SELF_HOSTED_CI_PEM }}
owner: ${{ env.SOURCE_REPO_OWNER }}
repositories: ${{ env.SOURCE_REPO_NAME }}
- name: Update Commit Status (Post)
if: ${{ always() && env.SOURCE_STATUS_REF != '' }}
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token-post.outputs.token }}
script: |
await github.rest.repos.createCommitStatus({
owner: process.env.SOURCE_REPO_OWNER,
repo: process.env.SOURCE_REPO_NAME,
sha: process.env.SOURCE_STATUS_REF,
state: "${{ steps.test.outcome == 'success' && 'success' || 'failure' }}",
description: "${{ steps.test.outcome == 'success' && 'Successful' || 'Failed' }}",
target_url: process.env.RUN_URL,
context: process.env.RUN_TARGET,
})