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
pull/370/head
zijiren 2 months ago committed by GitHub
parent a9e43f399b
commit bd9bf2bcee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -11,8 +11,8 @@ on:
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }} cancel-in-progress: true
permissions: permissions:
contents: read contents: read
@ -38,16 +38,17 @@ jobs:
- name: Check formatting - name: Check formatting
run: make fmt-check run: make fmt-check
# Build # Run Clippy lints independently from the test jobs.
build: clippy:
name: Build name: Clippy Lints
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
- name: Install Rust toolchain - name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- name: Install protobuf compiler - name: Install protobuf compiler
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
@ -55,11 +56,13 @@ jobs:
- name: Cache Rust build artifacts - name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Build - name: Run Clippy
run: make build-workspace timeout-minutes: 60
run: make clippy-check
proto-freshness: # Build
name: Proto Freshness build:
name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -74,12 +77,11 @@ jobs:
- name: Cache Rust build artifacts - name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Check generated proto artifacts - name: Build
run: make proto-freshness run: make build-workspace
# SQLx offline metadata proto-freshness:
sqlx-offline: name: Proto Freshness
name: SQLx Offline Check
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -94,40 +96,13 @@ jobs:
- name: Cache Rust build artifacts - name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Check SQLx offline metadata - name: Check generated proto artifacts
run: make check-all-targets run: make proto-freshness
feature-check: # SQLx offline metadata
name: Feature Check (${{ matrix.name }}) sqlx-offline:
name: SQLx Offline Check
runs-on: ubuntu-latest 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: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
@ -141,10 +116,8 @@ jobs:
- name: Cache Rust build artifacts - name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Run feature check - name: Check SQLx offline metadata
env: run: make check-all-targets
FEATURE_CHECK_ARGS: ${{ matrix.args }}
run: make ${{ matrix.target }}
# Test non-ignored cases # Test non-ignored cases
test-default: test-default:
@ -162,8 +135,6 @@ jobs:
- name: Install Rust toolchain - name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- name: Install cargo-nextest - name: Install cargo-nextest
uses: taiki-e/install-action@nextest uses: taiki-e/install-action@nextest
@ -187,10 +158,6 @@ jobs:
- name: Cache Rust build artifacts - name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Run clippy
timeout-minutes: 60
run: make clippy-check
- name: Run non-ignored tests with nextest - name: Run non-ignored tests with nextest
timeout-minutes: 60 timeout-minutes: 60
run: make nextest-default run: make nextest-default

@ -10,8 +10,8 @@ on:
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }} cancel-in-progress: true
permissions: permissions:
actions: read actions: read

@ -11,6 +11,10 @@ on:
- cron: '0 0 * * *' - cron: '0 0 * * *'
workflow_dispatch: workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
permissions: permissions:
contents: read contents: read

@ -14,8 +14,8 @@ on:
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }} cancel-in-progress: true
permissions: permissions:
contents: read contents: read

@ -30,8 +30,8 @@ on:
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: false cancel-in-progress: true
permissions: permissions:
contents: read contents: read

@ -27,9 +27,8 @@ ENV SQLX_OFFLINE=true
# fully explicit feature set. # fully explicit feature set.
ARG SYNCTV_BUILD_NO_DEFAULT_FEATURES=false ARG SYNCTV_BUILD_NO_DEFAULT_FEATURES=false
ARG SYNCTV_BUILD_FEATURES="k8s,mimalloc,openapi" ARG SYNCTV_BUILD_FEATURES="k8s,mimalloc,openapi"
ARG SYNCTV_BUILD_JOBS=1 ARG SYNCTV_CARGO_BUILD_ARGS=""
ARG TARGETARCH ARG TARGETARCH
ENV CARGO_BUILD_JOBS=$SYNCTV_BUILD_JOBS
# Copy entire source tree # Copy entire source tree
COPY . . 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,target=/usr/local/cargo/git \
--mount=type=cache,id=synctv-target-${TARGETARCH},target=/app/target,sharing=locked \ --mount=type=cache,id=synctv-target-${TARGETARCH},target=/app/target,sharing=locked \
build_flags="--release --bin synctv"; \ 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 \ if [ "$SYNCTV_BUILD_NO_DEFAULT_FEATURES" = "true" ]; then \
build_flags="$build_flags --no-default-features"; \ build_flags="$build_flags --no-default-features"; \
fi; \ fi; \

@ -64,7 +64,7 @@ pub async fn apple_app_site_association(
.unwrap_or_default(); .unwrap_or_default();
let document = apple_app_site_association_document( let document = apple_app_site_association_document(
app_ids, app_ids,
oauth2_app_link_paths(&allowed_redirect_urls, host), &oauth2_app_link_paths(&allowed_redirect_urls, host),
); );
Ok(( Ok((
[(header::CACHE_CONTROL, ASSOCIATION_CACHE_CONTROL)], [(header::CACHE_CONTROL, ASSOCIATION_CACHE_CONTROL)],
@ -74,7 +74,7 @@ pub async fn apple_app_site_association(
fn apple_app_site_association_document( fn apple_app_site_association_document(
app_ids: Vec<String>, app_ids: Vec<String>,
callback_paths: Vec<String>, callback_paths: &[String],
) -> AppleAppSiteAssociation { ) -> AppleAppSiteAssociation {
AppleAppSiteAssociation { AppleAppSiteAssociation {
applinks: AppleAppLinks { applinks: AppleAppLinks {
@ -83,7 +83,7 @@ fn apple_app_site_association_document(
.iter() .iter()
.map(|app_id| AppleAppLinkDetails { .map(|app_id| AppleAppLinkDetails {
app_id: app_id.clone(), app_id: app_id.clone(),
paths: callback_paths.clone(), paths: callback_paths.to_vec(),
}) })
.collect(), .collect(),
}, },
@ -171,7 +171,7 @@ mod tests {
); );
let document = apple_app_site_association_document( let document = apple_app_site_association_document(
vec!["85KBWFQ6F6.org.synctv.app".to_string()], vec!["85KBWFQ6F6.org.synctv.app".to_string()],
paths, &paths,
); );
assert_eq!( assert_eq!(
serde_json::to_value(document).expect("association document should serialize"), serde_json::to_value(document).expect("association document should serialize"),

@ -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)] #[serde(transparent)]
pub struct OAuth2AllowedRedirectUrls(pub Vec<String>); pub struct OAuth2AllowedRedirectUrls(pub Vec<String>);
impl Default for OAuth2AllowedRedirectUrls {
fn default() -> Self {
Self(Vec::new())
}
}
impl fmt::Display for OAuth2AllowedRedirectUrls { impl fmt::Display for OAuth2AllowedRedirectUrls {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&serde_json::to_string(&self.0).map_err(|_| fmt::Error)?) f.write_str(&serde_json::to_string(&self.0).map_err(|_| fmt::Error)?)

@ -288,7 +288,6 @@ async fn oauth2_service_with_provider_signup(
OAuth2ServiceRuntime { OAuth2ServiceRuntime {
runtime_settings_store: Some(runtime_settings_store), runtime_settings_store: Some(runtime_settings_store),
user_service: Some(Arc::new(create_user_service(pool))), user_service: Some(Arc::new(create_user_service(pool))),
..OAuth2ServiceRuntime::default()
}, },
) )
.checked("OAuth2 service should initialize") .checked("OAuth2 service should initialize")

Loading…
Cancel
Save