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
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ rustflags = ["-C", "target-feature=+crt-static"]
[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
[target.aarch64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
rustflags = ["-C", "target-feature=+crt-static"]

# Fix https://github.com/rust-lang/cargo/issues/8688
[http]
check-revoke = false
49 changes: 28 additions & 21 deletions .github/actions/download-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,50 @@ name: Download Artifact
description: Download file to local or artifact to quickly share files between jobs

inputs:
cache-type:
description: "Use github, local or lynx cache"
required: true
type: string
choices:
- github
- local
- lynx
name:
description: "Artifact name"
default: "artifact"
path:
description: "Destination path"
required: true
try-local-cache:
description: "Try use local cache to save artifact"
default: false
required: false
type: boolean
link-when-local:
description: "Link file instead of copy file"
default: false
type: boolean
required: false

runs:
using: composite
steps:
- name: Download artifact
- name: Download artifact from github
uses: actions/download-artifact@v4.1.7
if: ${{ startsWith(runner.name, 'GitHub Actions') || inputs.try-local-cache == 'false' }}
if: ${{ inputs.cache-type == 'github' }}
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
- name: Download local
if: ${{ !startsWith(runner.name, 'GitHub Actions') && inputs.try-local-cache == 'true' }}
- name: Download artifact from local
if: ${{ inputs.cache-type == 'local' }}
shell: bash
run: |
set -e
save_dir=$HOME/.cache/runner/${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }}
# download file
if [ "${{ inputs.link-when-local }}" = "true" ]; then
ln -sf $save_dir/* ${{ inputs.path }}
echo "ln -sf $save_dir/* ${{ inputs.path }}"
else
cp -rf $save_dir/* ${{ inputs.path }}
echo "cp -rf $save_dir/* ${{ inputs.path }}"
fi
ln -sf $save_dir/* ${{ inputs.path }}
echo "ln -sf $save_dir/* ${{ inputs.path }}"
- name: Download artifact from lynx
if: ${{ inputs.cache-type == 'lynx' }}
uses: lynx-infra/cache/restore@main
with:
path: ${{ inputs.path }}
key: rust-artifact-${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }}
restore-keys: |
rust-artifact-${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }}
env:
ACCESS_KEY: ${{ env.TOS_ACCESS_KEY }}
SECRET_KEY: ${{ env.TOS_SECRET_KEY }}
BUCKET_NAME: ${{ env.TOS_BUCKET_NAME }}
REGION: ${{ env.TOS_REGION }}
ENDPOINT: ${{ env.TOS_ENDPOINT }}
33 changes: 28 additions & 5 deletions .github/actions/pnpm-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ name: pnpm cache
description: Install Node.js with pnpm global cache

inputs:
type:
description: "Use github or local or lynx cache"
required: true
type: string
choices:
- github
- local
- lynx
node-version:
default: "20"
required: false
Expand Down Expand Up @@ -46,15 +54,30 @@ runs:
echo "STORE_PATH is $(pnpm store path)"
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Restore pnpm cache
id: restore
if: ${{ startsWith(runner.name, 'GitHub Actions') }}
uses: actions/cache/restore@v4
- name: Restore pnpm cache from Github
id: restore-from-github
if: ${{ inputs.type == 'github' }}
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
node-cache-${{ runner.os }}-pnpm-

- name: Restore pnpm cache from lynx
if: ${{ inputs.type == 'lynx' }}
uses: lynx-infra/cache@main
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
node-cache-${{ runner.os }}-pnpm-
env:
ACCESS_KEY: ${{ env.TOS_ACCESS_KEY }}
SECRET_KEY: ${{ env.TOS_SECRET_KEY }}
BUCKET_NAME: ${{ env.TOS_BUCKET_NAME }}
REGION: ${{ env.TOS_REGION }}
ENDPOINT: ${{ env.TOS_ENDPOINT }}

- name: Install dependencies
shell: bash
Expand All @@ -67,7 +90,7 @@ runs:

- name: Save pnpm cache
uses: actions/cache/save@v4
if: ${{ startsWith(runner.name, 'GitHub Actions') && inputs.save-if == 'true' && steps.restore.outputs.cache-hit != 'true' }}
if: ${{ inputs.type == 'github' && inputs.save-if == 'true' && steps.restore-from-github.outputs.cache-hit != 'true' }}
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
46 changes: 27 additions & 19 deletions .github/actions/upload-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ name: Upload Artifact
description: Upload file to local or artifact to quickly share files between jobs

inputs:
cache-type:
description: "Use github or local or lynx cache"
required: true
type: string
choices:
- github
- local
- lynx
name:
description: "Artifact name"
default: "artifact"
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
mv-when-local:
description: "Move file instead of copy file"
default: false
type: boolean
required: false

outputs:
runner-labels:
Expand All @@ -30,15 +28,29 @@ runs:
steps:
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ startsWith(runner.name, 'GitHub Actions') || inputs.try-local-cache == 'false' }}
if: ${{ inputs.cache-type == 'github' }}
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
if-no-files-found: error
overwrite: true

- name: Upload artifact
uses: lynx-infra/cache/save@main
if: ${{ inputs.cache-type == 'lynx' }}
with:
path: ${{ inputs.path }}
key: rust-artifact-${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }}
env:
ACCESS_KEY: ${{ env.TOS_ACCESS_KEY }}
SECRET_KEY: ${{ env.TOS_SECRET_KEY }}
BUCKET_NAME: ${{ env.TOS_BUCKET_NAME }}
REGION: ${{ env.TOS_REGION }}
ENDPOINT: ${{ env.TOS_ENDPOINT }}

- name: Upload local
id: upload-local
if: ${{ !startsWith(runner.name, 'GitHub Actions') && inputs.try-local-cache == 'true' }}
if: ${{ inputs.cache-type == 'local' }}
shell: bash
run: |
set -e
Expand All @@ -53,13 +65,9 @@ runs:
save_dir="$cache_dir/${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }}"
rm -rf $save_dir
mkdir $save_dir
if [ "${{ inputs.mv-when-local }}" = "true" ]; then
mv -f ${{ inputs.path }} $save_dir
echo "mv -f ${{ inputs.path }} $save_dir"
else
cp -rf ${{ inputs.path }} $save_dir
echo "cp -rf ${{ inputs.path }} $save_dir"
fi

mv -f ${{ inputs.path }} $save_dir
echo "mv -f ${{ inputs.path }} $save_dir"

# TODO echo machine name as runner labels
# echo "runner_labels=\"$(uname -n)\"" >> "$GITHUB_OUTPUT"
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}

env:
TOS_ACCESS_KEY: ${{ secrets.TOS_ACCESS_KEY }}
TOS_SECRET_KEY: ${{ secrets.TOS_SECRET_KEY }}
TOS_BUCKET_NAME: ${{ vars.TOS_BUCKET_NAME }}
TOS_REGION: ${{ vars.TOS_REGION }}
TOS_ENDPOINT: ${{ vars.TOS_ENDPOINT }}

jobs:
get-runner-labels:
name: Get Runner Labels
Expand Down Expand Up @@ -63,6 +70,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 }}
cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}

test-release-linux:
Expand All @@ -81,6 +90,8 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }}
cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }}

test-windows:
name: Test Windows
Expand All @@ -90,7 +101,12 @@ 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 }}
cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
secrets:
TOS_ACCESS_KEY: ${{ secrets.TOS_ACCESS_KEY }}
TOS_SECRET_KEY: ${{ secrets.TOS_SECRET_KEY }}

test-release-windows:
name: Test Release Windows
Expand All @@ -107,6 +123,11 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }}
cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }}
secrets:
TOS_ACCESS_KEY: ${{ secrets.TOS_ACCESS_KEY }}
TOS_SECRET_KEY: ${{ secrets.TOS_SECRET_KEY }}

test-mac:
name: Test Mac
Expand All @@ -117,6 +138,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 }}
cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}

test-release-mac:
Expand All @@ -133,6 +156,8 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }}
cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }}

cargo-deny:
name: Check license of dependencies
Expand Down Expand Up @@ -181,6 +206,8 @@ jobs:

- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache
with:
type: github

- name: Lint js
if: steps.changes.outputs.src == 'true'
Expand All @@ -203,6 +230,8 @@ jobs:

- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache
with:
type: github

- name: Run
run: |
Expand Down Expand Up @@ -241,6 +270,7 @@ jobs:
uses: ./.github/actions/pnpm-cache
with:
frozen-lockfile: true
type: github

rust_check:
name: Rust check
Expand All @@ -259,6 +289,8 @@ jobs:

- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
with:
type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }}

- name: Run Cargo Check
run: cargo check --workspace --all-targets --locked # Not using --release because it uses too much cache, and is also slow.
Expand Down Expand Up @@ -302,6 +334,8 @@ jobs:

- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
with:
type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }}

- name: Install Rust Toolchain
uses: ./.github/actions/rustup
Expand Down Expand Up @@ -330,6 +364,8 @@ jobs:

- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
with:
type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }}

- name: Install Rust Toolchain
uses: ./.github/actions/rustup
Expand Down Expand Up @@ -359,6 +395,8 @@ jobs:
- uses: actions/checkout@v4
- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
with:
type: github

- name: Install Rust Toolchain
uses: ./.github/actions/rustup
Expand Down
Loading
Loading