Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ci use k8s #8423

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: use runner-type
SyMind committed Nov 13, 2024
commit b7ac664facebfcf7390eb9299917244692e4d83c
25 changes: 18 additions & 7 deletions .github/actions/upload-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -9,11 +9,14 @@ inputs:
path:
description: "A file, directory or wildcard pattern that describes what to upload"
required: true
try-local-cache:
description: "Try use local cache to save artifact"
default: false
required: false
type: boolean
type:
description: "Use github or local or lynx cache"
required: true
type: string
choices:
- github
- local
- lynx
mv-when-local:
description: "Move file instead of copy file"
default: false
@@ -30,15 +33,23 @@ runs:
steps:
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ startsWith(runner.name, 'GitHub Actions') || inputs.try-local-cache == 'false' }}
if: ${{ inputs.type == 'github' }}
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
if-no-files-found: error
overwrite: true

- name: Upload artifact
uses: lynx-infra/cache
if: ${{ inputs.type == 'lynx' }}
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}

- name: Upload local
id: upload-local
if: ${{ !startsWith(runner.name, 'GitHub Actions') && inputs.try-local-cache == 'true' }}
if: ${{ inputs.type == 'local' }}
shell: bash
run: |
set -e
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -63,8 +63,8 @@ jobs:
target: x86_64-unknown-linux-gnu
profile: "debug"
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
ephemeral: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_EPHEMERAL }}

test-release-linux:
name: Test Release Linux
@@ -82,7 +82,7 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
ephemeral: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_EPHEMERAL }}
runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }}

test-windows:
name: Test Windows
@@ -92,8 +92,8 @@ jobs:
target: x86_64-pc-windows-msvc
profile: "debug"
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
ephemeral: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_EPHEMERAL }}

test-release-windows:
name: Test Release Windows
@@ -110,7 +110,7 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
ephemeral: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_EPHEMERAL }}
runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }}

test-mac:
name: Test Mac
@@ -121,8 +121,8 @@ jobs:
target: x86_64-apple-darwin
profile: "debug"
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
ephemeral: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_EPHEMERAL }}

test-release-mac:
name: Test Release Mac
@@ -138,7 +138,7 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
ephemeral: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_EPHEMERAL }}
runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }}

cargo-deny:
name: Check license of dependencies
18 changes: 9 additions & 9 deletions .github/workflows/get-runner-labels.yml
Original file line number Diff line number Diff line change
@@ -25,13 +25,13 @@ jobs:
runs-on: [self-hosted, Linux, ci]
outputs:
LINUX_RUNNER_LABELS: ${{ steps.run.outputs.LINUX_RUNNER_LABELS }}
LINUX_RUNNER_EPHEMERAL: ${{ steps.run.outputs.LINUX_RUNNERX_EPHEMERAL }}
LINUX_RUNNER_TYPE: ${{ steps.run.outputs.LINUX_RUNNER_TYPE }}

MACOS_RUNNER_LABELS: ${{ steps.run.outputs.MACOS_RUNNER_LABELS }}
MACOS_RUNNER_EPHEMERAL: ${{ steps.run.outputs.MACOS_RUNNER_EPHEMERAL }}
MACOS_RUNNER_TYPE: ${{ steps.run.outputs.MACOS_RUNNER_TYPE }}

WINDOWS_RUNNER_LABELS: ${{ steps.run.outputs.WINDOWS_RUNNER_LABELS }}
WINDOWS_RUNNER_EPHEMERAL: ${{ steps.run.outputs.WINDOWS_RUNNER_EPHEMERAL }}
WINDOWS_RUNNER_TYPE: ${{ steps.run.outputs.WINDOWS_RUNNER_TYPE }}
steps:
- id: run
shell: bash
@@ -53,22 +53,22 @@ jobs:
fi

if [[ "$LINUX_RUNNER_LABELS" == rspack-* ]]; then
LINUX_RUNNER_EPHEMERAL="false"
LINUX_RUNNER_TYPE="hosted"
else
LINUX_RUNNER_EPHEMERAL="true"
LINUX_RUNNER_TYPE="github"
fi
if [[ "$LINUX_RUNNER_LABELS" == rspack-* ]]; then
MACOS_RUNNER_EPHEMERAL="false"
MACOS_RUNNER_EPHEMERAL="hosted"
else
MACOS_RUNNER_EPHEMERAL="true"
MACOS_RUNNER_EPHEMERAL="github"
fi

# set output
echo "LINUX_RUNNER_LABELS=$LINUX_RUNNER_LABELS" >> "$GITHUB_OUTPUT"
echo "LINUX_RUNNER_EPHEMERAL=$LINUX_RUNNER_EPHEMERAL" >> "$GITHUB_OUTPUT"
echo "LINUX_RUNNER_TYPE=$LINUX_RUNNER_TYPE" >> "$GITHUB_OUTPUT"

echo "MACOS_RUNNER_LABELS=$MACOS_RUNNER_LABELS" >> "$GITHUB_OUTPUT"
echo "MACOS_RUNNER_EPHEMERAL=$MACOS_RUNNER_EPHEMERAL" >> "$GITHUB_OUTPUT"

echo "WINDOWS_RUNNER_LABELS='"volc-windows-2022-medium"'" >> "$GITHUB_OUTPUT"
echo "WINDOWS_RUNNER_EPHEMERAL='true'" >> "$GITHUB_OUTPUT"
echo "WINDOWS_RUNNER_TYPE='k8s'" >> "$GITHUB_OUTPUT"
10 changes: 10 additions & 0 deletions .github/workflows/preview-commit.yml
Original file line number Diff line number Diff line change
@@ -36,26 +36,36 @@ jobs:
array:
- target: x86_64-unknown-linux-gnu
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }}
- target: aarch64-unknown-linux-gnu
runner: "'ubuntu-latest'"
runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }}
- target: x86_64-unknown-linux-musl
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }}
- target: aarch64-unknown-linux-musl
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }}
- target: i686-pc-windows-msvc
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }}
- target: x86_64-pc-windows-msvc
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }}
- target: aarch64-pc-windows-msvc
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }}
- target: x86_64-apple-darwin
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }}
- target: aarch64-apple-darwin
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }}
uses: ./.github/workflows/reusable-build.yml
with:
target: ${{ matrix.array.target }}
runner: ${{ matrix.array.runner }}
runner-type: ${{ matrix.array.runner-type }}
profile: "release-prod"
test: false

20 changes: 10 additions & 10 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
@@ -42,6 +42,9 @@ on:
runner: # Runner labels
required: true
type: string
runner-type:
required: true
type: string
profile: # Rust profile, "debug" or "release"
default: "release"
required: false
@@ -53,9 +56,6 @@ on:
ref: # Git reference to checkout
required: false
type: string
ephemeral: # if the runner will automate clean up after a build
required: true
type: boolean

jobs:
build:
@@ -72,10 +72,10 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
clean: ${{ inputs.ephemeral }}
clean: ${{ inputs.runner-type == 'github' || inputs.runner-type == 'k8s' }}

- name: Clean
if: ${{ !inputs.skipable && !inputs.ephemeral }}
if: ${{ !inputs.skipable && inputs.runner-type == 'hosted' }}
uses: ./.github/actions/clean
with:
target: ${{ inputs.target }}
@@ -192,7 +192,7 @@ jobs:
- name: Build aarch64-apple-darwin
if: ${{ inputs.target == 'aarch64-apple-darwin' && steps.check_cache.outputs.files_exists != 'true' && !inputs.skipable }}
run: |
if [[ "${{ inputs.ephemeral }}" == "true" ]]; then
if [[ "${{ inputs.runner-type }}" == "github" ]]; then
# Github runner
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
fi
@@ -221,10 +221,10 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
clean: ${{ inputs.ephemeral }}
clean: ${{ inputs.runner-type == 'github' || inputs.runner-type == 'k8s' }}

- name: Clean
if: ${{ !inputs.ephemeral }}
if: ${{ inputs.runner-type == 'hosted' }}
uses: ./.github/actions/clean
with:
target: ${{ inputs.target }}
@@ -273,10 +273,10 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
clean: ${{ inputs.ephemeral }}
clean: ${{ inputs.runner-type == 'github' || inputs.runner-type == 'k8s' }}

- name: Clean
if: ${{ !inputs.skipable && !inputs.ephemeral }}
if: ${{ !inputs.skipable && inputs.runner-type == 'hosted' }}
uses: ./.github/actions/clean
with:
target: ${{ inputs.target }}