CI: use self-hosted runner if developer can create a branch in the up-stream repo (#5791)

* chore: use self hosted macos runner
This commit is contained in:
Nathan.fooo 2024-07-24 10:55:58 +08:00 committed by GitHub
parent 20e82880ff
commit 43b250ec28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 103 additions and 35 deletions

View File

@ -28,20 +28,35 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
build: build-self-hosted:
if: github.event.pull_request.draft != true if: github.event.pull_request.head.repo.full_name == github.repository
strategy: runs-on: self-hosted
fail-fast: true
matrix: steps:
os: [ macos-14 ] - name: Checkout source code
runs-on: ${{ matrix.os }} uses: actions/checkout@v2
- name: Build AppFlowy
working-directory: frontend
run: |
cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios
cargo make --profile development-ios-arm64-sim code_generation
- uses: futureware-tech/simulator-action@v3
id: simulator-action
with:
model: 'iPhone 15'
shutdown_after_job: false
build-macos:
if: github.event.pull_request.head.repo.full_name != github.repository
runs-on: macos-latest
steps: steps:
- name: Checkout source code - name: Checkout source code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install Rust toolchain - name: Install Rust toolchain
id: rust_toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
toolchain: ${{ env.RUST_TOOLCHAIN }} toolchain: ${{ env.RUST_TOOLCHAIN }}
@ -49,8 +64,7 @@ jobs:
override: true override: true
profile: minimal profile: minimal
- name: Install flutter - name: Install Flutter
id: flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
with: with:
channel: "stable" channel: "stable"
@ -59,7 +73,7 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
prefix-key: ${{ matrix.os }} prefix-key: macos-latest
workspaces: | workspaces: |
frontend/rust-lib frontend/rust-lib

View File

@ -23,17 +23,49 @@ env:
RUST_TOOLCHAIN: "1.77.2" RUST_TOOLCHAIN: "1.77.2"
jobs: jobs:
test-on-ubuntu: self-hosted-job:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: self-hosted
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Checkout Appflowy Cloud
uses: actions/checkout@v4
with:
repository: AppFlowy-IO/AppFlowy-Cloud
path: AppFlowy-Cloud
- name: Prepare Appflowy Cloud env
working-directory: AppFlowy-Cloud
run: |
cp deploy.env .env
sed -i '' 's|RUST_LOG=.*|RUST_LOG=trace|' .env
sed -i '' 's|API_EXTERNAL_URL=.*|API_EXTERNAL_URL=http://localhost|' .env
- name: Run rust-lib tests
working-directory: frontend/rust-lib
env:
RUST_LOG: info
RUST_BACKTRACE: 1
af_cloud_test_base_url: http://localhost
af_cloud_test_ws_url: ws://localhost/ws/v1
af_cloud_test_gotrue_url: http://localhost/gotrue
run: |
DISABLE_CI_TEST_LOG="true" cargo test --no-default-features --features="dart"
- name: rustfmt rust-lib
run: cargo fmt --all -- --check
working-directory: frontend/rust-lib/
- name: clippy rust-lib
run: cargo clippy --all-targets -- -D warnings
working-directory: frontend/rust-lib
ubuntu-job:
if: github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# - name: Maximize build space
# uses: easimon/maximize-build-space@master
# with:
# root-reserve-mb: 2048
# swap-size-mb: 1024
# remove-dotnet: 'true'
# the following step is required to avoid running out of space
- name: Maximize build space - name: Maximize build space
run: | run: |
sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/share/dotnet
@ -46,7 +78,6 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Rust toolchain - name: Install Rust toolchain
id: rust_toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
toolchain: ${{ env.RUST_TOOLCHAIN }} toolchain: ${{ env.RUST_TOOLCHAIN }}
@ -55,7 +86,7 @@ jobs:
profile: minimal profile: minimal
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
prefix-key: "ubuntu-latest" prefix-key: ${{ runner.os }}
cache-on-failure: true cache-on-failure: true
workspaces: | workspaces: |
frontend/rust-lib frontend/rust-lib
@ -69,7 +100,6 @@ jobs:
- name: Prepare appflowy cloud env - name: Prepare appflowy cloud env
working-directory: AppFlowy-Cloud working-directory: AppFlowy-Cloud
run: | run: |
# log level
cp deploy.env .env cp deploy.env .env
sed -i 's|RUST_LOG=.*|RUST_LOG=trace|' .env sed -i 's|RUST_LOG=.*|RUST_LOG=trace|' .env
sed -i 's|API_EXTERNAL_URL=.*|API_EXTERNAL_URL=http://localhost|' .env sed -i 's|API_EXTERNAL_URL=.*|API_EXTERNAL_URL=http://localhost|' .env

View File

@ -1,4 +1,5 @@
name: Tauri-CI name: Tauri-CI
on: on:
pull_request: pull_request:
paths: paths:
@ -17,22 +18,45 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
tauri-build: tauri-build-self-hosted:
if: github.event.pull_request.draft != true if: github.event.pull_request.head.repo.full_name == github.repository
strategy: runs-on: self-hosted
fail-fast: false
matrix:
platform: [ ubuntu-20.04 ]
runs-on: ${{ matrix.platform }}
env: env:
CI: true CI: true
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: install frontend dependencies
working-directory: frontend/appflowy_web_app
run: |
mkdir dist
pnpm install
cd src-tauri && cargo build
- name: test and lint
working-directory: frontend/appflowy_web_app
run: |
pnpm run lint:tauri
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tauriScript: pnpm tauri
projectPath: frontend/appflowy_web_app
args: "--debug"
tauri-build-ubuntu:
if: github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Maximize build space (ubuntu only) - name: Maximize build space (ubuntu only)
if: matrix.platform == 'ubuntu-20.04' if: matrix.os == 'ubuntu-latest'
run: | run: |
sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc sudo rm -rf /opt/ghc
@ -73,14 +97,14 @@ jobs:
key: node-modules-${{ runner.os }} key: node-modules-${{ runner.os }}
- name: install dependencies (windows only) - name: install dependencies (windows only)
if: matrix.platform == 'windows-latest' if: matrix.os == 'windows-latest'
working-directory: frontend working-directory: frontend
run: | run: |
cargo install --force duckscript_cli cargo install --force duckscript_cli
vcpkg integrate install vcpkg integrate install
- name: install dependencies (ubuntu only) - name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-20.04' if: matrix.os == 'ubuntu-latest'
working-directory: frontend working-directory: frontend
run: | run: |
sudo apt-get update sudo apt-get update