Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub actions for Rust #760

Merged
merged 9 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@

<!--- Make sure that the Travis tests pass in your PR -->
<!--- and that you are also using the elementary code style guidelines. -->
<!--- The code guideline is available here: https://elementary.io/docs/code/reference -->
<!--- The code guideline is available here: https://elementary.io/docs/code/reference -->

## Summary / How this PR fixes the problem?

<!--- Please write a description here -->

## Steps to Test
<!--- In case your change requires testing, this should show that your code is solid! -->

## Screenshots
<!--- In case your change requires testing, this should show that your code is solid! -->

## Screenshots

<!--- Share a screenshot with us if it was a visual change, -->
<!--- preferably with before/after shots -->

## Known Issues / Things To Do

<!--- If your PR is in progress or you know something is wrong with the code -->
<!--- write it here so we can help/discuss it -->
<!--- This is also a good place for a checklist with things left to fix in the PR -->

## This PR fixes/implements the following **bugs/features**:
<!--- If there was an issue that this PR targets, adding it here will auto close it -->

- Fixes #<!--- Replace me with Issue number -->
- Fixes #<!--- Replace me with Issue number -->
<!--- If there was an issue that this PR targets, adding it here will auto close it -->

- fixes #<!--- Replace me with Issue number -->
- fixes #<!--- Replace me with Issue number -->
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
open-pull-requests-limit: 15
schedule:
interval: "weekly"
allow:
# Allow both direct and indirect updates for all packages
- dependency-type: "all"
groups:
minor-patch:
update-types:
- "minor"
- "patch"

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "weekly"
67 changes: 43 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,61 @@
name: CI
name: "CI: build"

on: [pull_request]
on:
push:
branches: ["main"]
paths:
- "*.json"
pull_request:
branches: ["main"]
paths:
- "*.json"
types:
- opened
- reopened
- synchronize

jobs:
build:
runs-on: ubuntu-latest
container:
image: elementary/docker:unstable
steps:
- uses: actions/checkout@v1
- name: Install Dependencies
run: |
apt update
apt install -y libarchive-dev valac meson appstream-util xvfb at-spi2-core git build-essential autoconf autoconf-archive autopoint automake pkg-config libtool m4 autoconf-archive gtk-doc-tools libxml2-utils gobject-introspection libgirepository1.0-dev libglib2.0-dev libjson-glib-dev gettext libcairo2-dev libgtk-3-dev
- name: Build
run: |
meson build
ninja -C build
ninja -C build install
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true

jobs:
flatpak:
name: Flatpak
runs-on: ubuntu-latest

strategy:
matrix:
arch: [x86_64, aarch64]
# Don't fail the whole workflow if one architecture fails
fail-fast: false

container:
image: ghcr.io/elementary/flatpak-platform/runtime:6
image: ghcr.io/elementary/flatpak-platform/runtime:7.3-${{ matrix.arch }}
options: --privileged

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

- name: Install Rust SDK extension
run: |
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install -y --arch=${{matrix.arch}} org.freedesktop.Sdk.Extension.rust-stable//23.08

- name: Set up QEMU for aarch64 emulation
if: ${{ matrix.arch != 'x86_64' }}
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Build
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v3
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: akira-dev.flatpak
manifest-path: com.github.akiraux.akira.yml
run-tests: true
bundle: app.flatpak
manifest-path: io.github.davidmhewitt.ElementaryRustExample.json
run-tests: ${{ matrix.arch == 'x86_64' }}
repository-name: appcenter
repository-url: https://flatpak.elementary.io/repo.flatpakrepo
cache-key: "flatpak-builder-${{ github.sha }}"
branch: daily
arch: ${{ matrix.arch }}
76 changes: 68 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,80 @@
name: "CI: Lint"
name: "CI"

on:
push:
branches:
- "master"
branches: ["main"]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
lint:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/elementary/docker:stable

steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get update && apt-get install -y curl xvfb file
- name: Install stable rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- uses: actions/cache@v4
with:
path: |
./builddir
key: rust-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
rust-${{ runner.os }}
- name: Build
run: |
meson setup builddir
meson compile -C builddir
- name: Run tests
run: xvfb-run --auto-servernum meson test --print-errorlogs -C builddir

format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Install stable rust
run: |
rustup default stable
rustup set profile default
rustup update
- name: Touch empty config file
run: |
echo "" >> src/config.rs
- name: Run cargo fmt
run: |
cargo fmt --all -- --check

clippy:
runs-on: ubuntu-latest
container:
image: valalang/lint
image: ghcr.io/elementary/docker:stable

steps:
- uses: actions/checkout@v1
- name: Lint
run: io.elementary.vala-lint -d .
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get update && apt-get install -y curl
- name: Install stable rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Generate config.rs
run: |
meson setup builddir
- name: Run cargo clippy
run: |
cargo clippy -- -D warnings
39 changes: 39 additions & 0 deletions .github/workflows/sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "CI: Cargo sources"

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

on:
push:
branches: ["main"]
paths:
- "Cargo.lock"

permissions:
contents: write
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
path: repo

- uses: actions/checkout@v4
with:
repository: flatpak/flatpak-builder-tools
path: tools

- name: Update modules
run: |
sudo apt-get install -y python3-toml python3-aiohttp
python3 tools/cargo/flatpak-cargo-generator.py -o repo/cargo-sources.json repo/Cargo.lock
- uses: peter-evans/create-pull-request@v6
with:
path: repo
commit-message: Automated update of cargo-sources.json
title: Automated update of cargo-sources.json
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.snapcraft
.vscode
src/config.vala
src/config.rs
build/
builddir/
_build/
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
gettext-rs = "0.7.1"
gettext-rs = { version = "0.7", features = ["gettext-system"] }
granite = { version = "1.1", package = "granite-rs", features = ["v7_2"] }
gtk = { version = "0.9.1", package = "gtk4" }
once_cell = "1.19.0"
Loading