2023-01-03 14:34:55 +00:00
|
|
|
name: Rust-CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- "main"
|
2023-04-28 12:47:40 +00:00
|
|
|
- "develop"
|
2023-01-03 14:34:55 +00:00
|
|
|
- "release/*"
|
|
|
|
paths:
|
|
|
|
- "frontend/rust-lib/**"
|
2024-07-24 02:03:46 +00:00
|
|
|
- ".github/workflows/rust_ci.yaml"
|
2023-01-03 14:34:55 +00:00
|
|
|
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- "main"
|
2023-04-28 12:47:40 +00:00
|
|
|
- "develop"
|
2023-01-03 14:34:55 +00:00
|
|
|
- "release/*"
|
|
|
|
paths:
|
|
|
|
- "frontend/rust-lib/**"
|
|
|
|
|
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
2024-04-23 13:46:57 +00:00
|
|
|
RUST_TOOLCHAIN: "1.77.2"
|
2023-01-03 14:34:55 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-07-24 02:55:58 +00:00
|
|
|
self-hosted-job:
|
|
|
|
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
|
|
runs-on: self-hosted
|
2023-01-03 14:34:55 +00:00
|
|
|
steps:
|
2024-07-24 02:55:58 +00:00
|
|
|
- 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
|
2024-04-12 08:21:41 +00:00
|
|
|
|
2024-07-24 02:55:58 +00:00
|
|
|
- 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
|
|
|
|
steps:
|
2024-06-12 15:08:55 +00:00
|
|
|
- name: Maximize build space
|
|
|
|
run: |
|
|
|
|
sudo rm -rf /usr/share/dotnet
|
|
|
|
sudo rm -rf /opt/ghc
|
|
|
|
sudo rm -rf "/usr/local/share/boost"
|
|
|
|
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
|
|
|
sudo docker image prune --all --force
|
2024-03-07 04:50:28 +00:00
|
|
|
|
2023-01-03 14:55:30 +00:00
|
|
|
- name: Checkout source code
|
2024-02-17 13:38:12 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-01-03 14:55:30 +00:00
|
|
|
|
2023-01-03 14:34:55 +00:00
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
|
|
|
override: true
|
|
|
|
components: rustfmt, clippy
|
|
|
|
profile: minimal
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
with:
|
2024-07-24 02:55:58 +00:00
|
|
|
prefix-key: ${{ runner.os }}
|
2024-07-24 02:03:46 +00:00
|
|
|
cache-on-failure: true
|
2023-06-05 10:28:36 +00:00
|
|
|
workspaces: |
|
2023-08-17 15:46:39 +00:00
|
|
|
frontend/rust-lib
|
|
|
|
|
2023-12-25 18:03:42 +00:00
|
|
|
- name: Checkout appflowy cloud code
|
2024-02-17 13:38:12 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-12-25 18:03:42 +00:00
|
|
|
with:
|
|
|
|
repository: AppFlowy-IO/AppFlowy-Cloud
|
|
|
|
path: AppFlowy-Cloud
|
|
|
|
|
|
|
|
- name: Prepare appflowy cloud env
|
|
|
|
working-directory: AppFlowy-Cloud
|
|
|
|
run: |
|
2024-01-15 04:53:53 +00:00
|
|
|
cp deploy.env .env
|
2023-12-25 18:03:42 +00:00
|
|
|
sed -i 's|RUST_LOG=.*|RUST_LOG=trace|' .env
|
|
|
|
sed -i 's|API_EXTERNAL_URL=.*|API_EXTERNAL_URL=http://localhost|' .env
|
|
|
|
|
|
|
|
- name: Run Docker-Compose
|
|
|
|
working-directory: AppFlowy-Cloud
|
|
|
|
run: |
|
2024-07-24 23:59:03 +00:00
|
|
|
if [ "$(docker ps --filter name=appflowy-cloud -q)" == "" ]; then
|
|
|
|
docker compose pull
|
|
|
|
docker compose up -d
|
|
|
|
sleep 10
|
|
|
|
else
|
|
|
|
echo "Docker container 'appflowy-cloud' is already running."
|
|
|
|
fi
|
2023-12-25 18:03:42 +00:00
|
|
|
|
2023-06-07 14:27:13 +00:00
|
|
|
- name: Run rust-lib tests
|
|
|
|
working-directory: frontend/rust-lib
|
2024-01-15 04:53:53 +00:00
|
|
|
env:
|
|
|
|
RUST_LOG: info
|
|
|
|
RUST_BACKTRACE: 1
|
|
|
|
af_cloud_test_base_url: http://localhost
|
2024-03-10 08:02:30 +00:00
|
|
|
af_cloud_test_ws_url: ws://localhost/ws/v1
|
2024-01-15 04:53:53 +00:00
|
|
|
af_cloud_test_gotrue_url: http://localhost/gotrue
|
2024-03-30 08:28:24 +00:00
|
|
|
run: |
|
2024-05-05 14:04:34 +00:00
|
|
|
DISABLE_CI_TEST_LOG="true" cargo test --no-default-features --features="dart"
|
2024-01-15 04:53:53 +00:00
|
|
|
|
2023-01-03 14:34:55 +00:00
|
|
|
- name: rustfmt rust-lib
|
|
|
|
run: cargo fmt --all -- --check
|
|
|
|
working-directory: frontend/rust-lib/
|
|
|
|
|
|
|
|
- name: clippy rust-lib
|
2023-12-29 17:22:06 +00:00
|
|
|
run: cargo clippy --all-targets -- -D warnings
|
2024-01-16 18:59:15 +00:00
|
|
|
working-directory: frontend/rust-lib
|
2024-03-07 04:50:28 +00:00
|
|
|
|
2024-07-24 02:03:46 +00:00
|
|
|
- name: "Debug: show Appflowy-Cloud container logs"
|
|
|
|
if: failure()
|
|
|
|
working-directory: AppFlowy-Cloud
|
|
|
|
run: |
|
|
|
|
docker compose logs appflowy_cloud
|
|
|
|
|
2024-03-07 04:50:28 +00:00
|
|
|
- name: Clean up Docker images
|
|
|
|
run: |
|
|
|
|
docker image prune -af
|
|
|
|
docker volume prune -f
|