From bd9bf2bcee71ce85be9a99fa4f7c33d3f03cc054 Mon Sep 17 00:00:00 2001 From: zijiren <84728412+zijiren233@users.noreply.github.com> Date: Wed, 29 Jul 2026 21:38:13 +0800 Subject: [PATCH] build: expose generic cargo build arguments (#43) * build: expose generic cargo build arguments * fix: satisfy clippy after build argument cleanup * ci: run clippy independently and remove feature checks * ci: avoid duplicate push checks for pull requests * ci: deduplicate branch push and pull request runs * ci: isolate push and pull request concurrency groups --- .github/workflows/ci.yml | 81 ++++++------------- .github/workflows/codeql.yml | 4 +- .github/workflows/docker.yml | 4 + .github/workflows/docs.yml | 4 +- .github/workflows/helm-ci.yml | 4 +- Dockerfile | 6 +- .../src/http/native_app_association.rs | 8 +- .../src/service/global_settings/types.rs | 8 +- synctv-core/tests/user_auth_service_tests.rs | 1 - 9 files changed, 43 insertions(+), 77 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d243566..ac54e2b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,8 +11,8 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true permissions: contents: read @@ -38,16 +38,17 @@ jobs: - name: Check formatting run: make fmt-check - # Build - build: - name: Build + # Run Clippy lints independently from the test jobs. + clippy: + name: Clippy Lints runs-on: ubuntu-latest - steps: - uses: actions/checkout@v5 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@nightly + with: + components: clippy - name: Install protobuf compiler run: sudo apt-get update && sudo apt-get install -y protobuf-compiler @@ -55,11 +56,13 @@ jobs: - name: Cache Rust build artifacts uses: Swatinem/rust-cache@v2 - - name: Build - run: make build-workspace + - name: Run Clippy + timeout-minutes: 60 + run: make clippy-check - proto-freshness: - name: Proto Freshness + # Build + build: + name: Build runs-on: ubuntu-latest steps: @@ -74,12 +77,11 @@ jobs: - name: Cache Rust build artifacts uses: Swatinem/rust-cache@v2 - - name: Check generated proto artifacts - run: make proto-freshness + - name: Build + run: make build-workspace - # SQLx offline metadata - sqlx-offline: - name: SQLx Offline Check + proto-freshness: + name: Proto Freshness runs-on: ubuntu-latest steps: @@ -94,40 +96,13 @@ jobs: - name: Cache Rust build artifacts uses: Swatinem/rust-cache@v2 - - name: Check SQLx offline metadata - run: make check-all-targets + - name: Check generated proto artifacts + run: make proto-freshness - feature-check: - name: Feature Check (${{ matrix.name }}) + # SQLx offline metadata + sqlx-offline: + name: SQLx Offline Check runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - name: synctv-no-default-features - target: feature-check - args: --no-default-features - - name: synctv-tls-aws-lc-webpki - target: feature-check - args: --no-default-features --features tls-aws-lc,tls-webpki-roots - - name: synctv-tls-aws-lc-native - target: feature-check - args: --no-default-features --features tls-aws-lc,tls-native-roots - - name: synctv-tls-ring-webpki - target: feature-check - args: --no-default-features --features tls-ring,tls-webpki-roots - - name: synctv-tls-ring-native - target: feature-check - args: --no-default-features --features tls-ring,tls-native-roots - - name: synctv-production-default - target: feature-check - args: --features tls-native-roots - - name: synctv-openapi - target: feature-check - args: --features openapi - - name: key-crates-tls-ring-webpki - target: feature-check-key-crates-tls-ring-webpki - args: "" steps: - uses: actions/checkout@v5 @@ -141,10 +116,8 @@ jobs: - name: Cache Rust build artifacts uses: Swatinem/rust-cache@v2 - - name: Run feature check - env: - FEATURE_CHECK_ARGS: ${{ matrix.args }} - run: make ${{ matrix.target }} + - name: Check SQLx offline metadata + run: make check-all-targets # Test non-ignored cases test-default: @@ -162,8 +135,6 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@nightly - with: - components: clippy - name: Install cargo-nextest uses: taiki-e/install-action@nextest @@ -187,10 +158,6 @@ jobs: - name: Cache Rust build artifacts uses: Swatinem/rust-cache@v2 - - name: Run clippy - timeout-minutes: 60 - run: make clippy-check - - name: Run non-ignored tests with nextest timeout-minutes: 60 run: make nextest-default diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 72af63c3..374cca42 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -10,8 +10,8 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true permissions: actions: read diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c0efae97..5193e5a7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,6 +11,10 @@ on: - cron: '0 0 * * *' workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + permissions: contents: read diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9b546da4..e2f3b307 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,8 +14,8 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true permissions: contents: read diff --git a/.github/workflows/helm-ci.yml b/.github/workflows/helm-ci.yml index 80f6aa51..849cef47 100644 --- a/.github/workflows/helm-ci.yml +++ b/.github/workflows/helm-ci.yml @@ -30,8 +30,8 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true permissions: contents: read diff --git a/Dockerfile b/Dockerfile index 8d3d4e9b..a69f5bcf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,9 +27,8 @@ ENV SQLX_OFFLINE=true # fully explicit feature set. ARG SYNCTV_BUILD_NO_DEFAULT_FEATURES=false ARG SYNCTV_BUILD_FEATURES="k8s,mimalloc,openapi" -ARG SYNCTV_BUILD_JOBS=1 +ARG SYNCTV_CARGO_BUILD_ARGS="" ARG TARGETARCH -ENV CARGO_BUILD_JOBS=$SYNCTV_BUILD_JOBS # Copy entire source tree COPY . . @@ -40,6 +39,9 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/usr/local/cargo/git \ --mount=type=cache,id=synctv-target-${TARGETARCH},target=/app/target,sharing=locked \ build_flags="--release --bin synctv"; \ + if [ -n "$SYNCTV_CARGO_BUILD_ARGS" ]; then \ + build_flags="$build_flags $SYNCTV_CARGO_BUILD_ARGS"; \ + fi; \ if [ "$SYNCTV_BUILD_NO_DEFAULT_FEATURES" = "true" ]; then \ build_flags="$build_flags --no-default-features"; \ fi; \ diff --git a/synctv-api-http/src/http/native_app_association.rs b/synctv-api-http/src/http/native_app_association.rs index e293138d..2648c82d 100644 --- a/synctv-api-http/src/http/native_app_association.rs +++ b/synctv-api-http/src/http/native_app_association.rs @@ -64,7 +64,7 @@ pub async fn apple_app_site_association( .unwrap_or_default(); let document = apple_app_site_association_document( app_ids, - oauth2_app_link_paths(&allowed_redirect_urls, host), + &oauth2_app_link_paths(&allowed_redirect_urls, host), ); Ok(( [(header::CACHE_CONTROL, ASSOCIATION_CACHE_CONTROL)], @@ -74,7 +74,7 @@ pub async fn apple_app_site_association( fn apple_app_site_association_document( app_ids: Vec, - callback_paths: Vec, + callback_paths: &[String], ) -> AppleAppSiteAssociation { AppleAppSiteAssociation { applinks: AppleAppLinks { @@ -83,7 +83,7 @@ fn apple_app_site_association_document( .iter() .map(|app_id| AppleAppLinkDetails { app_id: app_id.clone(), - paths: callback_paths.clone(), + paths: callback_paths.to_vec(), }) .collect(), }, @@ -171,7 +171,7 @@ mod tests { ); let document = apple_app_site_association_document( vec!["85KBWFQ6F6.org.synctv.app".to_string()], - paths, + &paths, ); assert_eq!( serde_json::to_value(document).expect("association document should serialize"), diff --git a/synctv-core/src/service/global_settings/types.rs b/synctv-core/src/service/global_settings/types.rs index a521ce44..353c9785 100644 --- a/synctv-core/src/service/global_settings/types.rs +++ b/synctv-core/src/service/global_settings/types.rs @@ -364,16 +364,10 @@ impl std::str::FromStr for CorsAllowedOrigins { } } -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] #[serde(transparent)] pub struct OAuth2AllowedRedirectUrls(pub Vec); -impl Default for OAuth2AllowedRedirectUrls { - fn default() -> Self { - Self(Vec::new()) - } -} - impl fmt::Display for OAuth2AllowedRedirectUrls { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&serde_json::to_string(&self.0).map_err(|_| fmt::Error)?) diff --git a/synctv-core/tests/user_auth_service_tests.rs b/synctv-core/tests/user_auth_service_tests.rs index 4f9c7d27..b27b4575 100644 --- a/synctv-core/tests/user_auth_service_tests.rs +++ b/synctv-core/tests/user_auth_service_tests.rs @@ -288,7 +288,6 @@ async fn oauth2_service_with_provider_signup( OAuth2ServiceRuntime { runtime_settings_store: Some(runtime_settings_store), user_service: Some(Arc::new(create_user_service(pool))), - ..OAuth2ServiceRuntime::default() }, ) .checked("OAuth2 service should initialize")