Skip to content

Commit

Permalink
meta: Rewrite CI to use flatpak.
Browse files Browse the repository at this point in the history
  • Loading branch information
luleyleo committed Sep 9, 2024
1 parent f5e596f commit c5fb532
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 208 deletions.
149 changes: 41 additions & 108 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: CI

on:
push:
branches:
Expand All @@ -6,113 +8,44 @@ on:
branches:
- main

env:
RUST_VERSION: 1.80.0
CARGO_TERM_COLOR: always
DEPENDENCIES: libgtk-4-1 libgtk-4-dev libadwaita-1-0 libadwaita-1-dev build-essential

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt install ${{ env.DEPENDENCIES }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
override: true
components: clippy

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets --all-features -- -D warnings

test:
name: Test Suite
runs-on: ubuntu-latest
CI:
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt install ${{ env.DEPENDENCIES }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
override: true

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
# --all-targets includes --benches, which we don't want.
args: --workspace --all-features --lib --bins --tests --examples --verbose

rustfmt:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install nightly toolchain with rustfmt available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check --verbose

doc:
name: Doc
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -D warnings
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt install ${{ env.DEPENDENCIES }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
override: true

- name: Run cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --no-deps --verbose

- name: Run cargo test --doc
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features --doc --verbose
- uses: actions/checkout@v3

- name: Install host dependencies
run: |
sudo apt-get install flatpak flatpak-builder just
# Restore caches
- name: Restore Flatpak dependencies
uses: actions/cache/restore@v3
with:
path: ~/.local/share/flatpak
key: ${{ runner.os }}-flatpak-dependencies-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-flatpak-dependencies-
- name: Restore .flatpak-builder
uses: actions/cache/restore@v3
with:
path: .flatpak-builder
key: ${{ runner.os }}-flatpak-builder-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-flatpak-builder-
- run: just ci

# Save caches
- name: Save Flatpak dependencies
uses: actions/cache/save@v3
if: always()
with:
path: ~/.local/share/flatpak
key: ${{ runner.os }}-flatpak-dependencies-${{ github.run_id }}
- name: Save .flatpak-builder
uses: actions/cache/save@v3
if: always()
with:
path: .flatpak-builder
key: ${{ runner.os }}-flatpak-builder-${{ github.run_id }}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ debian/*
!debian/rules
!debian/source

.flatpak-builder
assets/locale
flatpak/
.flatpak-builder/
assets/locale/
101 changes: 5 additions & 96 deletions build-aux/cargo-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,97 +285,6 @@
"dest": "cargo/vendor/dotext-0.1.1",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/encoding/encoding-0.2.33.crate",
"sha256": "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec",
"dest": "cargo/vendor/encoding-0.2.33"
},
{
"type": "inline",
"contents": "{\"package\": \"6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec\", \"files\": {}}",
"dest": "cargo/vendor/encoding-0.2.33",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/encoding-index-japanese/encoding-index-japanese-1.20141219.5.crate",
"sha256": "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91",
"dest": "cargo/vendor/encoding-index-japanese-1.20141219.5"
},
{
"type": "inline",
"contents": "{\"package\": \"04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91\", \"files\": {}}",
"dest": "cargo/vendor/encoding-index-japanese-1.20141219.5",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/encoding-index-korean/encoding-index-korean-1.20141219.5.crate",
"sha256": "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81",
"dest": "cargo/vendor/encoding-index-korean-1.20141219.5"
},
{
"type": "inline",
"contents": "{\"package\": \"4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81\", \"files\": {}}",
"dest": "cargo/vendor/encoding-index-korean-1.20141219.5",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/encoding-index-simpchinese/encoding-index-simpchinese-1.20141219.5.crate",
"sha256": "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7",
"dest": "cargo/vendor/encoding-index-simpchinese-1.20141219.5"
},
{
"type": "inline",
"contents": "{\"package\": \"d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7\", \"files\": {}}",
"dest": "cargo/vendor/encoding-index-simpchinese-1.20141219.5",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/encoding-index-singlebyte/encoding-index-singlebyte-1.20141219.5.crate",
"sha256": "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a",
"dest": "cargo/vendor/encoding-index-singlebyte-1.20141219.5"
},
{
"type": "inline",
"contents": "{\"package\": \"3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a\", \"files\": {}}",
"dest": "cargo/vendor/encoding-index-singlebyte-1.20141219.5",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/encoding-index-tradchinese/encoding-index-tradchinese-1.20141219.5.crate",
"sha256": "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18",
"dest": "cargo/vendor/encoding-index-tradchinese-1.20141219.5"
},
{
"type": "inline",
"contents": "{\"package\": \"fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18\", \"files\": {}}",
"dest": "cargo/vendor/encoding-index-tradchinese-1.20141219.5",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/encoding_index_tests/encoding_index_tests-0.1.4.crate",
"sha256": "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569",
"dest": "cargo/vendor/encoding_index_tests-0.1.4"
},
{
"type": "inline",
"contents": "{\"package\": \"a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569\", \"files\": {}}",
"dest": "cargo/vendor/encoding_index_tests-0.1.4",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
Expand Down Expand Up @@ -1458,14 +1367,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/pdf-extract/pdf-extract-0.7.7.crate",
"sha256": "3423481005e61b95855d53d7b6c0bcc514b4fbab45d165776d6e42c0a1642b22",
"dest": "cargo/vendor/pdf-extract-0.7.7"
"url": "https://static.crates.io/crates/pdf-extract/pdf-extract-0.7.9.crate",
"sha256": "fcbc6f659da931cc7108b6dd3b2e3703792cc4c3a562c35ab9c3bf38895f107f",
"dest": "cargo/vendor/pdf-extract-0.7.9"
},
{
"type": "inline",
"contents": "{\"package\": \"3423481005e61b95855d53d7b6c0bcc514b4fbab45d165776d6e42c0a1642b22\", \"files\": {}}",
"dest": "cargo/vendor/pdf-extract-0.7.7",
"contents": "{\"package\": \"fcbc6f659da931cc7108b6dd3b2e3703792cc4c3a562c35ab9c3bf38895f107f\", \"files\": {}}",
"dest": "cargo/vendor/pdf-extract-0.7.9",
"dest-filename": ".cargo-checksum.json"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"type": "dir",
"path": ".."
},
"../build-aux/cargo-sources.json"
"./cargo-sources.json"
]
}
]
Expand Down
3 changes: 3 additions & 0 deletions build-aux/fun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

flatpak-builder --run $(dirname $0)/../flatpak $(dirname $0)/de.leopoldluley.Clapgrep.json "$@"
15 changes: 14 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ check *args:
run *args: build-translations
env RUST_BACKTRACE=full cargo run --package {{frontend}} {{args}}

ci: setup-flatpak-repos
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/{{appid}}.json
echo Check formatting:
./build-aux/fun.sh cargo fmt --all -- --check --verbose
echo Check code:
./build-aux/fun.sh cargo check
echo Check code with Clippy:
./build-aux/fun.sh cargo clippy --workspace --all-targets --all-features -- -D warnings

install:
mkdir -p {{po-dst}}
install -Dm0755 {{bin-src}} {{bin-dst}}
Expand All @@ -57,9 +66,13 @@ make-makefile:
prepare-flatpak: make-makefile
python3 build-aux/flatpak-cargo-generator.py ./Cargo.lock -o build-aux/cargo-sources.json

install-flatpak:
install-flatpak: setup-flatpak-repos
flatpak-builder flatpak-build gnome/de.leopoldluley.Clapgrep.json --force-clean --install --user

setup-flatpak-repos:
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//46 org.freedesktop.Sdk.Extension.rust-stable//23.08

gettext *args:
xgettext \
--from-code=UTF-8 \
Expand Down

0 comments on commit c5fb532

Please sign in to comment.