diff options
| author | ruki <[email protected]> | 2026-01-05 11:24:06 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-05 11:24:06 +0800 |
| commit | c8ecdbe7283ec7478ee4f855b5e878aaa16c3fa6 (patch) | |
| tree | c70bb9af823341a8878a67464ce4bcdf175e991e | |
| parent | 5631b98caa40ad06994f983a7c2a500be4b0e2b2 (diff) | |
| parent | f49b27c442870afeaf42a98fb187097845bf814d (diff) | |
Merge pull request #7186 from xmake-io/alpine
Add alpine ci
| -rw-r--r-- | .github/workflows/alpine.yml | 91 | ||||
| -rw-r--r-- | tests/projects/linux/bpf/minimal/test.lua | 2 | ||||
| -rw-r--r-- | tests/projects/package/components/test.lua | 3 |
3 files changed, 95 insertions, 1 deletions
diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml new file mode 100644 index 000000000..5bce09441 --- /dev/null +++ b/.github/workflows/alpine.yml @@ -0,0 +1,91 @@ +name: Alpine + +on: + pull_request: + push: + release: + 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: | + const fs = require('fs'); + const outputFile = process.env.GITHUB_OUTPUT; + + // Always run for release events + if (context.eventName === 'release') { + fs.appendFileSync(outputFile, `should-run=true\n`); + 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; + + // Use environment file instead of deprecated set-output + fs.appendFileSync(outputFile, `should-run=${shouldRun}\n`); + 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.ALPINE_RUN_PROBABILITY || '0.2' }} + + build: + needs: check + if: needs.check.outputs.should-run == 'true' + + container: alpine:latest + runs-on: ubuntu-latest + + concurrency: + # Prevent concurrent runs of the same workflow + group: Alpine-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false + steps: + - name: Prepare build tools + run: | + uname -a + apk --no-cache add grep linux-headers bash curl git unzip build-base tar 7zip perl + + - uses: actions/checkout@v2 + with: + submodules: true + + - name: prepare local xmake + run: | + cp -rf . ../xmake-source + - uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: local#../xmake-source + + - name: Tests + env: + XMAKE_ROOT: y + run: | + xmake lua -v -D tests/run.lua + xrepo --version + diff --git a/tests/projects/linux/bpf/minimal/test.lua b/tests/projects/linux/bpf/minimal/test.lua index 2856a3831..5b01d6685 100644 --- a/tests/projects/linux/bpf/minimal/test.lua +++ b/tests/projects/linux/bpf/minimal/test.lua @@ -1,5 +1,5 @@ function main(t) - if is_host("linux") and os.arch() == "x86_64" then + if is_host("linux") and os.arch() == "x86_64" and linuxos.name() ~= "alpine" then os.vrun("xmake f -y -p android -vD") os.vrun("xmake -y -vD") end diff --git a/tests/projects/package/components/test.lua b/tests/projects/package/components/test.lua index fdec596a7..a7e71bb89 100644 --- a/tests/projects/package/components/test.lua +++ b/tests/projects/package/components/test.lua @@ -2,6 +2,9 @@ function main(t) if is_host("bsd", "solaris") or is_subhost("msys") then return end + if is_host("linux") and linuxos.name() == "alpine" then + return + end -- only for x86/x64, because it will take too long time on ci with arm/mips if os.subarch():startswith("x") or os.subarch() == "i386" then |
