Compare commits
3 Commits
07ca0cae5a
...
e6e658e014
| Author | SHA1 | Date | |
|---|---|---|---|
| e6e658e014 | |||
| 8260f0db4c | |||
| 85256bf559 |
110
.github/workflows/main.yaml
vendored
110
.github/workflows/main.yaml
vendored
@@ -6,71 +6,75 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
name: Lint code & run tests
|
name: Run lints & tests
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
container: alpine:3.21
|
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- name: Install dependencies
|
- name: Checkout repository
|
||||||
run: apk add cargo coreutils docker git nodejs rust-clippy rustfmt tar zstd
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Setup rust
|
||||||
uses: actions/checkout@v4
|
uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0
|
||||||
|
id: toolchain
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
targets: x86_64-unknown-linux-musl
|
||||||
|
components: clippy, rustfmt
|
||||||
|
|
||||||
- name: Get Cargo.lock hash
|
- name: Setup cache
|
||||||
id: hash
|
uses: actions/cache@v4
|
||||||
run: |
|
with:
|
||||||
hash="$(sha256sum Cargo.lock | awk '{print $1}')"
|
path: |
|
||||||
echo "hash=$hash" >>"$GITHUB_OUTPUT"
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
key: cargo-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('Cargo.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
cargo-${{ steps.toolchain.outputs.cachekey }}-
|
||||||
|
cargo-
|
||||||
|
|
||||||
- name: Setup cache
|
- name: Run fmt
|
||||||
uses: actions/cache@v3
|
run: cargo fmt --all --check
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/bin/
|
|
||||||
~/.cargo/registry/index/
|
|
||||||
~/.cargo/registry/cache/
|
|
||||||
~/.cargo/git/db/
|
|
||||||
target/
|
|
||||||
key: zpk-cargo-${{ steps.hash.outputs.hash }}
|
|
||||||
restore-keys: |
|
|
||||||
zpk-cargo-
|
|
||||||
|
|
||||||
- name: Run fmt
|
- name: Run check
|
||||||
run: cargo fmt --all --check
|
run: cargo check
|
||||||
|
|
||||||
- name: Run check
|
- name: Run clippy
|
||||||
run: cargo check
|
run: cargo clippy -- -D warnings
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Download apk
|
||||||
run: cargo clippy -- -D warnings
|
run: |
|
||||||
|
wget -O apk https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic//v2.14.10/x86_64/apk.static
|
||||||
|
chmod +x apk
|
||||||
|
echo "$(pwd)" >>"$GITHUB_PATH"
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: cargo test
|
run: cargo test
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build binary
|
||||||
run: cargo build
|
run: cargo build --target x86_64-unknown-linux-musl
|
||||||
|
|
||||||
- name: Start test container
|
- name: Start integration test container
|
||||||
id: container
|
id: container
|
||||||
run: |
|
run: |
|
||||||
id="$(docker run --rm --privileged -d alpine:3.21 tail -f /dev/null)"
|
id="$(docker run --rm --privileged -d alpine:3.21 tail -f /dev/null)"
|
||||||
echo "id=$id" >>"$GITHUB_OUTPUT"
|
echo "id=$id" >>"$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Copy scripts
|
- name: Copy scripts
|
||||||
run: |
|
run: |
|
||||||
docker cp ./scripts/integration.sh "$ID":/tmp/
|
docker cp ./scripts/integration.sh "$ID":/tmp/
|
||||||
docker cp ./target/debug/zpk "$ID":/usr/bin/
|
docker cp ./target/x86_64-unknown-linux-musl/debug/zpk "$ID":/usr/bin/
|
||||||
env:
|
env:
|
||||||
ID: ${{ steps.container.outputs.id }}
|
ID: ${{ steps.container.outputs.id }}
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run integration tests
|
||||||
run: docker exec -i -u 0 "$ID" /tmp/integration.sh
|
run: docker exec -i -u 0 "$ID" /tmp/integration.sh
|
||||||
env:
|
env:
|
||||||
ID: ${{ steps.container.outputs.id }}
|
ID: ${{ steps.container.outputs.id }}
|
||||||
|
|
||||||
- name: Stop test container
|
- name: Stop integration test container
|
||||||
if: always()
|
if: always()
|
||||||
run: docker stop "$ID"
|
run: docker stop -t0 "$ID"
|
||||||
env:
|
env:
|
||||||
ID: ${{ steps.container.outputs.id }}
|
ID: ${{ steps.container.outputs.id }}
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
"group:allNonMajor",
|
"group:allNonMajor",
|
||||||
"schedule:monthly",
|
"schedule:monthly",
|
||||||
],
|
],
|
||||||
"enabledManagers": ["cargo"],
|
"enabledManagers": ["cargo", "github-actions"],
|
||||||
"osvVulnerabilityAlerts": true
|
"osvVulnerabilityAlerts": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ fn get_repo_dir_from(path: &Path) -> eyre::Result<String> {
|
|||||||
.lines()
|
.lines()
|
||||||
.filter(|line| line.starts_with("REPODEST="))
|
.filter(|line| line.starts_with("REPODEST="))
|
||||||
.map(|line| line.trim_start_matches("REPODEST="))
|
.map(|line| line.trim_start_matches("REPODEST="))
|
||||||
.last();
|
.next_back();
|
||||||
let home_dir = dirs_sys::home_dir().unwrap();
|
let home_dir = dirs_sys::home_dir().unwrap();
|
||||||
let repo_dir = PathBuf::from(if let Some(repodest) = repodest {
|
let repo_dir = PathBuf::from(if let Some(repodest) = repodest {
|
||||||
// This should probably be done with proper shell interpolation.
|
// This should probably be done with proper shell interpolation.
|
||||||
|
|||||||
Reference in New Issue
Block a user