Skip to content

Commit

Permalink
CI, sync with rers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik authored and gquintard committed Oct 24, 2024
1 parent f439d29 commit cbbd020
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 20 deletions.
49 changes: 35 additions & 14 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
name: Build
on: [push]

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
workflow_dispatch:

jobs:
main:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false # 7.6 is not yet supported properly. Once fixed, this can be set to true
matrix:
include:
- setup: varnish74
- setup: varnish75
- setup: varnish76
env:
RUST_BACKTRACE: 1
RUSTDOCFLAGS: -D warnings
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: |
sudo apt-get install -y curl
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish75/script.deb.sh | sudo bash
sudo apt-get install varnish-dev
- run: |
cargo doc
cargo build
cargo test
- uses: taiki-e/install-action@v2
with: { tool: just }
- uses: actions/checkout@v4
- name: Ensure this crate has not yet been published (on release)
if: github.event_name == 'release'
run: just check-if-published
- uses: Swatinem/rust-cache@v2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
- name: install varnish-dev
run: |
curl -s https://packagecloud.io/install/repositories/varnishcache/${{ matrix.setup }}/script.deb.sh | sudo bash
sudo apt-get install -y varnish-dev
- run: just -v ci-test
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ edition = "2021"
license = "BSD-3-Clause"

[dependencies]
varnish = { git = "https://github.com/nyurik/varnish-rs.git", branch = "fixes-for-reqwest"}
varnish-sys = { git = "https://github.com/nyurik/varnish-rs.git", branch = "fixes-for-reqwest"}
varnish-macros = { git = "https://github.com/nyurik/varnish-rs.git", branch = "fixes-for-reqwest" }
chrono = "0.4.23"
varnish = { git = "https://github.com/gquintard/varnish-rs.git", branch = "feature-macro"}
varnish-macros = { git = "https://github.com/gquintard/varnish-rs.git", branch = "feature-macro" }
varnish-sys = { git = "https://github.com/gquintard/varnish-rs.git", branch = "feature-macro"}

[lib]
crate-type = ["cdylib"]
69 changes: 69 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env just --justfile

@_default:
just --list --unsorted

# Clean all build artifacts
clean:
cargo clean
rm -f Cargo.lock

# Update dependencies, including breaking changes
update:
cargo +nightly -Z unstable-options update --breaking
cargo update

# Run cargo clippy
clippy:
cargo clippy --workspace --all-targets -- -D warnings

# Test code formatting
test-fmt:
cargo fmt --all -- --check

# Run cargo fmt
fmt:
cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate

# Build and open code documentation
docs:
cargo doc --no-deps --open

# Quick compile
check:
cargo check --workspace --all-targets

# Default build
build:
cargo build --workspace --all-targets

# Run all tests
test: build
cargo test --workspace --all-targets

# Test documentation
test-doc:
cargo doc --no-deps

rust-info:
rustc --version
cargo --version

# Run all tests as expected by CI
ci-test: rust-info test-fmt clippy test test-doc

# Verify that the current version of the crate is not the same as the one published on crates.io
check-if-published:
#!/usr/bin/env bash
LOCAL_VERSION="$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]*)".*/\1/')"
echo "Detected crate version: $LOCAL_VERSION"
CRATE_NAME="$(grep '^name =' Cargo.toml | head -1 | sed -E 's/name = "(.*)"/\1/')"
echo "Detected crate name: $CRATE_NAME"
PUBLISHED_VERSION="$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E 's/.* = "(.*)".*/\1/')"
echo "Published crate version: $PUBLISHED_VERSION"
if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "ERROR: The current crate version has already been published."
exit 1
else
echo "The current crate version has not yet been published."
fi

0 comments on commit cbbd020

Please sign in to comment.