github: fix self-hosted runner checkout issues #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-License-Identifier: GPL-2.0 | |
| --- | |
| name: Run kdevops CI Workflow - Push/PR/Manual/Schedule | |
| on: | |
| schedule: | |
| - cron: '0 14 * * *' # Daily at 2 PM UTC | |
| push: | |
| branches: | |
| - '**' | |
| pull_request: | |
| branches: | |
| - '**' | |
| workflow_dispatch: | |
| inputs: | |
| ci_workflow: | |
| description: "CI Workflow" | |
| required: true | |
| default: 'blktests_nvme' | |
| type: choice | |
| options: | |
| - blktests | |
| - blktests_block | |
| - blktests_loop | |
| - blktests_meta | |
| - blktests_nbd | |
| - blktests_nvme | |
| - blktests_nvmemp | |
| - blktests_scsi | |
| - blktests_srp | |
| - blktests_zbd | |
| - lbs-xfs | |
| - lbs-xfs-bdev-large-nvme | |
| - lbs-xfs-bdev-nvme | |
| - lbs-xfs-small | |
| - xfs | |
| - xfs-soak | |
| - xfs_crc | |
| - xfs_crc_logdev | |
| - xfs_crc_rtdev | |
| - xfs_crc_rtdev_extsize_28k | |
| - xfs_crc_rtdev_extsize_64k | |
| - xfs_nocrc | |
| - xfs_nocrc_16k_4ks | |
| - xfs_nocrc_1k | |
| - xfs_nocrc_2k | |
| - xfs_nocrc_32_4ks | |
| - xfs_nocrc_4k | |
| - xfs_nocrc_512 | |
| - xfs_nocrc_64_4ks | |
| - xfs_nocrc_8k_4ks | |
| - xfs_nocrc_lbs | |
| - xfs_reflink | |
| - xfs_reflink_1024 | |
| - xfs_reflink_16k_4ks | |
| - xfs_reflink_2k | |
| - xfs_reflink_32k_4ks | |
| - xfs_reflink_4k | |
| - xfs_reflink_4k_8ks | |
| - xfs_reflink_64k_4ks | |
| - xfs_reflink_dir_bsize_8k | |
| - xfs_reflink_lbs | |
| - xfs_reflink_logdev | |
| - xfs_reflink_normapbt | |
| - xfs_reflink_nrext64 | |
| - xfs_reflink_stripe_len | |
| kernel_tree: | |
| description: "Linux kernel tree to use" | |
| required: true | |
| default: 'linux' | |
| type: choice | |
| options: | |
| - linux | |
| - linux-next | |
| - linux-stable | |
| kernel_ref: | |
| description: "Linux tree git reference (branch/tag/commit-id)" | |
| required: true | |
| default: 'master' | |
| type: string | |
| test_mode: | |
| description: 'Testing mode' | |
| required: false | |
| default: 'kdevops-ci' | |
| type: choice | |
| options: | |
| - 'kdevops-ci' | |
| - 'linux-ci' | |
| tests: | |
| description: 'Custom test to run (for kdevops-ci mode only)' | |
| required: false | |
| type: string | |
| default: '' | |
| jobs: | |
| generate_kernel_ref: | |
| name: Generate Kernel Reference for Scheduled Runs | |
| runs-on: [self-hosted] | |
| if: github.event_name == 'schedule' | |
| outputs: | |
| kernel_ref: ${{ steps.kernel_ref.outputs.kernel_ref }} | |
| kernel_tree: ${{ steps.kernel_ref.outputs.kernel_tree }} | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Generate kernel reference based on day of week | |
| id: kernel_ref | |
| run: | | |
| set -euxo pipefail | |
| day_of_week=$(date +%u) | |
| if [ "$day_of_week" -eq 1 ]; then | |
| # Monday: Use mainline | |
| kernel_ref=$(./scripts/korg-releases.py --moniker mainline) | |
| kernel_tree=linux | |
| else | |
| # Other days: Use linux-next | |
| kernel_ref=$(./scripts/korg-releases.py --moniker linux-next) | |
| kernel_tree=linux-next | |
| fi | |
| ./scripts/github_output.sh kernel_ref "$kernel_ref" | |
| ./scripts/github_output.sh kernel_tree "$kernel_tree" | |
| check_ref: | |
| name: Check Linux kernel Git Reference | |
| runs-on: [self-hosted] | |
| if: github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Check kernel_ref exists | |
| id: check_kernel_ref | |
| run: | | |
| set -euxo pipefail | |
| ref="${{ github.event.inputs.kernel_ref }}" | |
| tree="${{ github.event.inputs.kernel_tree }}" | |
| mirror="/mirror/${tree}.git" | |
| ls_remote="$(git ls-remote "$mirror" "refs/*/${ref}" || true)" | |
| contains_branch="$(git -C "$mirror" branch --contains "${ref}" || true)" | |
| contains_tag="$(git -C "$mirror" branch --contains "${ref}" || true)" | |
| if [ -z "$ls_remote" ] && [ -z "$contains_branch" ] && [ -z "$contains_tag" ]; then | |
| echo "Linux kernel ${ref} does not exist." | |
| exit 1 | |
| fi | |
| kdevops-ci-matrix: | |
| name: "${{ github.event.inputs.test_mode || 'kdevops-ci' }}: ${{ matrix.ci_workflow }}" | |
| runs-on: self-hosted | |
| needs: [check_ref, generate_kernel_ref] | |
| if: >- | |
| always() && | |
| ( | |
| needs.check_ref.result == 'success' || | |
| needs.check_ref.result == 'skipped' | |
| ) && | |
| ( | |
| needs.generate_kernel_ref.result == 'success' || | |
| needs.generate_kernel_ref.result == 'skipped' | |
| ) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ci_workflow: >- | |
| ${{ | |
| github.event_name == 'schedule' | |
| && fromJSON('["blktests"]') | |
| || github.event_name == 'workflow_dispatch' | |
| && fromJSON(format('["{0}"]', github.event.inputs.ci_workflow)) | |
| || fromJSON('["blktests_nvme", "xfs_reflink_4k"]') | |
| }} | |
| steps: | |
| - name: Checkout repository for ${{ matrix.ci_workflow }} | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| # More efficient approach similar to actions/checkout | |
| if [[ -d ".git" ]]; then | |
| # Repo exists - clean and update (like actions/checkout) | |
| git clean -ffdx | |
| git reset --hard HEAD | |
| # Ensure correct remote URL for public repo | |
| git remote set-url origin ${{ github.server_url }}/${{ github.repository }}.git | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| # For PRs, fetch the specific PR ref that GitHub creates | |
| git fetch --depth=1 origin refs/pull/${{ github.event.number }}/head:pr-branch | |
| git checkout pr-branch | |
| else | |
| # For push/schedule/workflow_dispatch, use the commit SHA directly | |
| git fetch --depth=1 origin ${{ github.sha }} | |
| git checkout ${{ github.sha }} | |
| fi | |
| else | |
| # No repo - fresh clone with local mirror optimization | |
| if [[ -f "/mirror/kdevops.git/HEAD" ]]; then | |
| git clone --verbose --progress \ | |
| --reference /mirror/kdevops.git \ | |
| --depth=1 \ | |
| ${{ github.server_url }}/${{ github.repository }}.git . | |
| else | |
| git clone --verbose --progress \ | |
| --depth=1 \ | |
| ${{ github.server_url }}/${{ github.repository }}.git . | |
| fi | |
| # Checkout the specific commit | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| git fetch --depth=1 origin refs/pull/${{ github.event.number }}/head:pr-branch | |
| git checkout pr-branch | |
| else | |
| git checkout ${{ github.sha }} | |
| fi | |
| fi | |
| - name: Configure kdevops | |
| uses: ./.github/actions/configure | |
| with: | |
| ci_workflow: ${{ matrix.ci_workflow }} | |
| kernel_ref: >- | |
| ${{ | |
| github.event_name == 'schedule' && needs.generate_kernel_ref.outputs.kernel_ref | |
| || github.event.inputs.kernel_ref | |
| || 'v6.15' | |
| }} | |
| kernel_tree: >- | |
| ${{ | |
| github.event_name == 'schedule' && needs.generate_kernel_ref.outputs.kernel_tree | |
| || github.event.inputs.kernel_tree | |
| || 'linux' | |
| }} | |
| test_mode: >- | |
| ${{ | |
| github.event_name == 'schedule' && 'linux-ci' | |
| || github.event.inputs.test_mode | |
| || 'kdevops-ci' | |
| }} | |
| - name: Bringup guests | |
| uses: ./.github/actions/bringup | |
| - name: Install linux | |
| uses: ./.github/actions/linux | |
| - name: Install tests | |
| uses: ./.github/actions/build-test | |
| with: | |
| ci_workflow: ${{ matrix.ci_workflow }} | |
| - name: Run tests | |
| uses: ./.github/actions/test | |
| with: | |
| ci_workflow: ${{ matrix.ci_workflow }} | |
| test_mode: ${{ github.event.inputs.test_mode || 'kdevops-ci' }} | |
| tests: ${{ github.event.inputs.tests || '' }} | |
| timeout-minutes: 120 | |
| - name: Archive results | |
| uses: ./.github/actions/archive | |
| with: | |
| ci_workflow: ${{ matrix.ci_workflow }} | |
| ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| - name: Cleanup | |
| if: always() | |
| uses: ./.github/actions/cleanup |