Skip to content

Commit

Permalink
Fork: Restore rust workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinevg committed Jul 30, 2024
1 parent 7461273 commit 6e1b99a
Showing 1 changed file with 150 additions and 0 deletions.
150 changes: 150 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
on:
push:
pull_request:
workflow_dispatch:

# Run automatically every monday
schedule:
- cron: 1 12 * * 1

name: CI

jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-4-dev build-essential
version: 2

- uses: Swatinem/rust-cache@v2

- name: Install toolchain
run: |
rustup toolchain install stable
rustup default stable
- name: Run clippy
run: cargo clippy -- --deny warnings

build_and_test:
name: Build and test
strategy:
fail-fast: false
matrix:
os: ['macos-latest', 'ubuntu-latest', 'windows-latest']
rust: ['stable', '1.74']

runs-on: ${{ matrix.os }}

env:
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg/installed

steps:
- uses: actions/checkout@v4

- name: Install toolchain
run: |
rustup toolchain install ${{ matrix.rust }}
rustup default ${{ matrix.rust }}
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-4-dev build-essential
version: 2
if: startsWith(matrix.os, 'ubuntu-')

- name: Install dependencies (macOS)
run: brew install gtk4
if: matrix.os == 'macos-latest'

- name: Install cargo-wix (Windows)
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-wix
if: matrix.os == 'windows-latest'

- name: Install cargo-license (Windows)
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-license
if: matrix.os == 'windows-latest'

- name: Install dependencies (Windows)
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 01f602195983451bc83e72f4214af2cbc495aa94 # 2024.05.24 release
runVcpkgInstall: true
doNotCache: false
if: matrix.os == 'windows-latest'

- name: Set PKG_CONFIG (Windows)
run: echo "PKG_CONFIG=$env:VCPKG_INSTALLED_DIR/x64-windows/tools/pkgconf/pkgconf.exe" | Out-File -FilePath $env:GITHUB_ENV -Append
if: matrix.os == 'windows-latest'

- name: Set PKG_CONFIG_PATH (Windows)
run: echo "PKG_CONFIG_PATH=$env:VCPKG_INSTALLED_DIR/x64-windows/lib/pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
if: matrix.os == 'windows-latest'

- name: Set PATH (Windows)
run: echo "$env:VCPKG_INSTALLED_DIR/x64-windows/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
if: matrix.os == 'windows-latest'

- name: Build
run: cargo build --release

- name: Test
run: cargo test
if: runner.os != 'Linux'

- name: Test under XVFB (Linux)
run: xvfb-run cargo test
if: runner.os == 'Linux'

- name: Compile glib schemas (Windows)
run: |
& "$env:VCPKG_INSTALLED_DIR/x64-windows/tools/glib/glib-compile-schemas.exe" "$env:VCPKG_INSTALLED_DIR/x64-windows/share/glib-2.0/schemas"
if: matrix.os == 'windows-latest'

- name: Gather licenses (Windows)
# If the default shell is used, one command failing does not fail the action.
shell: bash
run: |
pip install license-expression
python wix/rust_licenses.py > wix/LICENSE-static-libraries.txt
python wix/vcpkg_licenses.py > wix/LICENSE-dynamic-libraries.txt
if: matrix.os == 'windows-latest'

- name: Generate components (Windows)
run: |
python wix/generate_components.py
if: matrix.os == 'windows-latest'

- name: Build installer (Windows)
run: cargo wix --no-build --nocapture -v
if: matrix.os == 'windows-latest'

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: Binary for ${{ matrix.os }}
path: |
target/release/packetry
target/release/packetry.exe
if-no-files-found: error
if: matrix.rust == 'stable'

- name: Upload installer (Windows)
uses: actions/upload-artifact@v4
with:
name: Windows installer
path: |
target/wix/*.msi
if-no-files-found: error
if: runner.os == 'Windows' && matrix.rust == 'stable'

0 comments on commit 6e1b99a

Please sign in to comment.