diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ef6b0dd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable + with: + toolchain: stable + components: clippy, rustfmt + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 + - run: cargo fmt --check + - run: cargo clippy --all-targets --release -- -D warnings + - run: cargo test --release + - run: shellcheck bin/gh-img scripts/*.sh deploy/install.sh + - run: sudo apt-get update -q && sudo apt-get install -y -q libimage-exiftool-perl + - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 + with: + # no lockfile to key the cache on + enable-cache: false + - run: scripts/check-fixtures.sh + + build: + runs-on: ubuntu-latest + env: + TARGET: x86_64-unknown-linux-musl + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable + with: + toolchain: stable + targets: x86_64-unknown-linux-musl + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 + - uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 + with: + version: 0.16.0 + - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21 + with: + tool: cargo-zigbuild@0.23.4 + - run: cargo zigbuild --release --target "$TARGET" + - name: Check the binary is static + run: | + info=$(file "target/$TARGET/release/gh-img-server") + echo "$info" + grep -Eq 'statically linked|static-pie linked' <<<"$info" + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: gh-img-server-${{ env.TARGET }} + path: target/${{ env.TARGET }}/release/gh-img-server + retention-days: 7 + if-no-files-found: error