Skip to content

Commit

Permalink
Add dependency caching to GH Actions for faster CI (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
escritorio-gustavo authored Mar 8, 2024
1 parent cb5d081 commit 92082fb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 22 deletions.
62 changes: 47 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ jobs:
e2e-dependencies:
name: Run 'dependencies' end-to-end test
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: dependencies e2e test
working-directory: e2e/dependencies/consumer
run: |
Expand All @@ -23,11 +25,13 @@ jobs:
e2e-workspace:
name: Run 'workspace' end-to-end test
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: workspace e2e test
working-directory: e2e/workspace
run: |
Expand All @@ -45,11 +49,13 @@ jobs:
e2e-example:
name: End-to-end test example
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: example e2e test
working-directory: example
run: |
Expand All @@ -65,40 +71,66 @@ jobs:
readme-up-to-date:
name: Check that README.md is up-to-date
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Check that README.md is up-to-date
working-directory: ts-rs
run: |
cargo install cargo-readme
diff -u ../README.md <(cargo readme)
test:
name: Test ts-rs
test-all-features:
name: Test ts-rs with --all-features
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Test with export env
- uses: Swatinem/rust-cache@v2
- name: Test
run: |
cargo test --all-features
shopt -s globstar
tsc ts-rs/bindings/**/*.ts --noEmit --noUnusedLocals --strict
rm -rf ts-rs/bindings
test-export-env:
name: Test ts-rs with TS_RS_EXPORT_DIR
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Test
run: |
TS_RS_EXPORT_DIR=output cargo test --no-default-features
shopt -s globstar
tsc ts-rs/output/**/*.ts --noEmit --noUnusedLocals --strict
rm -rf ts-rs/output
- name: No features
test-no-features:
name: Test ts-rs with --no-default-features
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Test
run: |
cargo test --no-default-features
shopt -s globstar
tsc ts-rs/bindings/**/*.ts --noEmit --noUnusedLocals
rm -rf ts-rs/bindings
- name: All features
run: |
cargo test --all-features
shopt -s globstar
tsc ts-rs/bindings/**/*.ts --noEmit --noUnusedLocals --strict
rm -rf ts-rs/bindings
9 changes: 5 additions & 4 deletions e2e/dependencies/consumer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use ts_rs::TS;
#![allow(dead_code)]

use dependency1::*;
use ts_rs::TS;

#[derive(TS)]
#[ts(export)]
Expand All @@ -19,8 +21,7 @@ struct T0;
#[derive(TS)]
#[ts(export)]
struct T1 {
t0: Option<T0>
t0: Option<T0>,
}


fn main() {}
fn main() {}
6 changes: 3 additions & 3 deletions e2e/dependencies/dependency1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use ts_rs::TS;

#[derive(TS)]
pub struct LibraryType1 {
pub a: i32
pub a: i32,
}

#[derive(TS)]
pub struct LibraryType2<T> {
pub t: T
pub t: T,
}

#[derive(TS)]
pub struct LibraryType3;
pub struct LibraryType3;

0 comments on commit 92082fb

Please sign in to comment.