Skip to content

Commit

Permalink
Add github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
james-w committed Jul 12, 2024
1 parent 45f2c29 commit b2511bd
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 4 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/cacheclean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: cleanup caches on a merged PR
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
30 changes: 30 additions & 0 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Cargo Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
cargo:
timeout-minutes: 12
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
# Sync with dockerfiles/cargo-base/Dockerfile
toolchain: 1.75
override: true
components: rustfmt, clippy
- name: Setup cargo cache
uses: Swatinem/rust-cache@v2
continue-on-error: false
- name: Run cargo fmt
run: cargo fmt --check
- name: Run tests
run: cargo test
- name: Check lint
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run cargo check
run: cargo check
3 changes: 1 addition & 2 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,7 @@ mod tests {

#[test]
fn uses_globals() {
let mut config = Config::default();
config.globals = Some(HashMap::new());
let mut config = Config { globals: Some(HashMap::new()), ..Default::default() };
config
.globals
.as_mut()
Expand Down
10 changes: 8 additions & 2 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ pub struct TestContext {
pub workdir: assert_fs::TempDir,
}

impl TestContext {
pub fn new() -> Self {
impl Default for TestContext {
fn default() -> Self {
Self {
workdir: assert_fs::TempDir::new().unwrap(),
}
}
}

impl TestContext {
pub fn new() -> Self {
Self::default()
}

pub fn workdir(&self) -> &std::path::Path {
self.workdir.path()
Expand Down

0 comments on commit b2511bd

Please sign in to comment.