diff options
| author | ruki <[email protected]> | 2025-11-25 08:22:18 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-25 08:22:18 +0800 |
| commit | 41c58ffac305d96a6a61fe6d78107ca56c691a8f (patch) | |
| tree | 96ef6c0f29d11684b390677a63bf4c538bb0cc30 | |
| parent | dd9c1b43a0c9ac0410c1188c6ab37dacccab30d5 (diff) | |
| parent | b94e6bf744334691af95fba9797616e2ba782a25 (diff) | |
Merge pull request #7059 from xmake-io/ci
improve ci
| -rw-r--r-- | .github/workflows/archlinux.yml | 50 | ||||
| -rw-r--r-- | .github/workflows/dragonflybsd.yml | 51 | ||||
| -rw-r--r-- | .github/workflows/fedora.yml | 50 | ||||
| -rw-r--r-- | .github/workflows/linux_luajit.yml | 50 | ||||
| -rw-r--r-- | .github/workflows/netbsd.yml | 51 | ||||
| -rw-r--r-- | .github/workflows/openbsd.yml | 51 | ||||
| -rw-r--r-- | .github/workflows/windows_luajit.yml | 50 |
7 files changed, 336 insertions, 17 deletions
diff --git a/.github/workflows/archlinux.yml b/.github/workflows/archlinux.yml index 7ca627271..1c87e03b3 100644 --- a/.github/workflows/archlinux.yml +++ b/.github/workflows/archlinux.yml @@ -7,14 +7,60 @@ on: types: [published] jobs: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + // Always run for release events + if (context.eventName === 'release') { + core.setOutput('should-run', true); + core.info('Release event detected. Will run tests.'); + return; + } + + // Execution probability (default 20%, can be overridden via env) + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + + // Generate deterministic "random" number based on commit SHA, run ID, and current time + // Adding time ensures better randomness while keeping same commit/run consistent + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; // Convert to 32-bit integer + } + // Normalize to 0-1 range + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + core.setOutput('should-run', shouldRun); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.ARCHLINUX_RUN_PROBABILITY || '0.2' }} + build: + needs: check + if: needs.check.outputs.should-run == 'true' container: archlinux:base-devel runs-on: ubuntu-latest concurrency: - group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Archlinux - cancel-in-progress: true + # Prevent concurrent runs of the same workflow + group: Archlinux-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false steps: - name: Prepare build tools run: | diff --git a/.github/workflows/dragonflybsd.yml b/.github/workflows/dragonflybsd.yml index e30bc1376..53ed7a02e 100644 --- a/.github/workflows/dragonflybsd.yml +++ b/.github/workflows/dragonflybsd.yml @@ -7,13 +7,58 @@ on: types: [published] jobs: - build: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + // Always run for release events + if (context.eventName === 'release') { + core.setOutput('should-run', true); + core.info('Release event detected. Will run tests.'); + return; + } + + // Execution probability (default 20%, can be overridden via env) + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + + // Generate deterministic "random" number based on commit SHA, run ID, and current time + // Adding time ensures better randomness while keeping same commit/run consistent + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; // Convert to 32-bit integer + } + // Normalize to 0-1 range + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + core.setOutput('should-run', shouldRun); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.DRAGONFLYBSD_RUN_PROBABILITY || '0.2' }} + build: + needs: check + if: needs.check.outputs.should-run == 'true' runs-on: ubuntu-latest concurrency: - group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-DragonflyBSD - cancel-in-progress: true + # Prevent concurrent runs of the same workflow + group: DragonflyBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index eb2617523..3b6a66ba7 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -7,14 +7,60 @@ on: types: [published] jobs: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + // Always run for release events + if (context.eventName === 'release') { + core.setOutput('should-run', true); + core.info('Release event detected. Will run tests.'); + return; + } + + // Execution probability (default 20%, can be overridden via env) + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + + // Generate deterministic "random" number based on commit SHA, run ID, and current time + // Adding time ensures better randomness while keeping same commit/run consistent + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; // Convert to 32-bit integer + } + // Normalize to 0-1 range + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + core.setOutput('should-run', shouldRun); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.FEDORA_RUN_PROBABILITY || '0.2' }} + build: + needs: check + if: needs.check.outputs.should-run == 'true' container: fedora:latest runs-on: ubuntu-latest concurrency: - group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Fedora - cancel-in-progress: true + # Prevent concurrent runs of the same workflow + group: Fedora-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false steps: - name: Prepare build tools run: | diff --git a/.github/workflows/linux_luajit.yml b/.github/workflows/linux_luajit.yml index acec3fbce..8d47c9093 100644 --- a/.github/workflows/linux_luajit.yml +++ b/.github/workflows/linux_luajit.yml @@ -7,11 +7,57 @@ on: types: [published] jobs: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + // Always run for release events + if (context.eventName === 'release') { + core.setOutput('should-run', true); + core.info('Release event detected. Will run tests.'); + return; + } + + // Execution probability (default 20%, can be overridden via env) + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + + // Generate deterministic "random" number based on commit SHA, run ID, and current time + // Adding time ensures better randomness while keeping same commit/run consistent + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; // Convert to 32-bit integer + } + // Normalize to 0-1 range + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + core.setOutput('should-run', shouldRun); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.LINUX_LUAJIT_RUN_PROBABILITY || '0.2' }} + build: + needs: check + if: needs.check.outputs.should-run == 'true' runs-on: ubuntu-latest concurrency: - group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Linux-Luajit - cancel-in-progress: true + # Prevent concurrent runs of the same workflow + group: Linux-Luajit-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/netbsd.yml b/.github/workflows/netbsd.yml index 0ee1a8077..6d1bbd163 100644 --- a/.github/workflows/netbsd.yml +++ b/.github/workflows/netbsd.yml @@ -7,13 +7,58 @@ on: types: [published] jobs: - build: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + // Always run for release events + if (context.eventName === 'release') { + core.setOutput('should-run', true); + core.info('Release event detected. Will run tests.'); + return; + } + + // Execution probability (default 20%, can be overridden via env) + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + + // Generate deterministic "random" number based on commit SHA, run ID, and current time + // Adding time ensures better randomness while keeping same commit/run consistent + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; // Convert to 32-bit integer + } + // Normalize to 0-1 range + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + core.setOutput('should-run', shouldRun); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.NETBSD_RUN_PROBABILITY || '0.2' }} + build: + needs: check + if: needs.check.outputs.should-run == 'true' runs-on: ubuntu-latest concurrency: - group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-NetBSD - cancel-in-progress: true + # Prevent concurrent runs of the same workflow + group: NetBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/openbsd.yml b/.github/workflows/openbsd.yml index 18d95b056..a0314e7ef 100644 --- a/.github/workflows/openbsd.yml +++ b/.github/workflows/openbsd.yml @@ -7,13 +7,58 @@ on: types: [published] jobs: - build: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + // Always run for release events + if (context.eventName === 'release') { + core.setOutput('should-run', true); + core.info('Release event detected. Will run tests.'); + return; + } + + // Execution probability (default 20%, can be overridden via env) + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + + // Generate deterministic "random" number based on commit SHA, run ID, and current time + // Adding time ensures better randomness while keeping same commit/run consistent + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; // Convert to 32-bit integer + } + // Normalize to 0-1 range + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + core.setOutput('should-run', shouldRun); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.OPENBSD_RUN_PROBABILITY || '0.2' }} + build: + needs: check + if: needs.check.outputs.should-run == 'true' runs-on: ubuntu-latest concurrency: - group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-OpenBSD - cancel-in-progress: true + # Prevent concurrent runs of the same workflow + group: OpenBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/windows_luajit.yml b/.github/workflows/windows_luajit.yml index 69fa55b69..3d2ad1292 100644 --- a/.github/workflows/windows_luajit.yml +++ b/.github/workflows/windows_luajit.yml @@ -7,7 +7,52 @@ on: types: [published] jobs: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + // Always run for release events + if (context.eventName === 'release') { + core.setOutput('should-run', true); + core.info('Release event detected. Will run tests.'); + return; + } + + // Execution probability (default 20%, can be overridden via env) + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + + // Generate deterministic "random" number based on commit SHA, run ID, and current time + // Adding time ensures better randomness while keeping same commit/run consistent + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; // Convert to 32-bit integer + } + // Normalize to 0-1 range + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + core.setOutput('should-run', shouldRun); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.WINDOWS_LUAJIT_RUN_PROBABILITY || '0.2' }} + build: + needs: check + if: needs.check.outputs.should-run == 'true' strategy: matrix: os: [windows-2022, windows-2025] @@ -16,8 +61,9 @@ jobs: runs-on: ${{ matrix.os }} concurrency: - group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.arch }}-Windows-Luajit - cancel-in-progress: true + # Prevent concurrent runs of the same workflow + group: Windows-Luajit-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }}-${{ matrix.os }}-${{ matrix.arch }} + cancel-in-progress: false steps: - uses: actions/checkout@v2 with: |
