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

feat(ci): validate appstream #181

Merged
merged 5 commits into from
Jan 1, 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
48 changes: 41 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,48 @@ name: Specs & Lint

on: [push, pull_request]
jobs:
ci:
lint:
runs-on: ubuntu-latest
container: ghcr.io/geopjr/crystal-gtk:latest
steps:
- uses: actions/checkout@v3
- name: Shards install & Generate bindings
run: make bindings
- name: Spec
run: crystal spec -Dpreview_mt --order random || exit 1
- uses: actions/checkout@v4
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
- name: Check formatting
run: crystal tool format --check
flatpak-builder:
name: "Flatpak Builder"
runs-on: ubuntu-latest
needs: [ lint ]
container:
image: bilelmoussaoui/flatpak-github-actions:gnome-45
options: --privileged
strategy:
matrix:
arch:
- x86_64
# - aarch64
# Don't fail the whole workflow if one architecture fails
# fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Validate AppStream
run: appstreamcli validate ./data/dev.geopjr.Collision.metainfo.xml.in
# Docker is required by the docker/setup-qemu-action which enables emulation
# - name: Install deps
# if: matrix.arch == 'aarch64'
# run: dnf -y install docker
# - name: Set up QEMU
# if: matrix.arch == 'aarch64'
# id: qemu
# uses: docker/setup-qemu-action@v2
# with:
# platforms: arm64
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: "dev.geopjr.Collision.Devel.flatpak"
run-tests: true
manifest-path: "data/dev.geopjr.Collision.json"
cache-key: flatpak-builder-${{ github.sha }}
arch: ${{ matrix.arch }}
repository-name: flathub-beta
repository-url: https://flathub.org/beta-repo/flathub-beta.flatpakrepo
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all install uninstall test build mo desktop gresource bindings install_nautilus_extension
.PHONY: all install uninstall test check build mo desktop gresource bindings install_nautilus_extension
PREFIX ?= /usr
PO_LOCATION ?= po
LOCALE_LOCATION ?= /share/locale
Expand All @@ -11,7 +11,7 @@ bindings:
build:
COLLISION_LOCALE_LOCATION="$(PREFIX)$(LOCALE_LOCATION)" $(CRYSTAL_LOCATION)shards build -Dpreview_mt --release --no-debug

test:
check test:
$(CRYSTAL_LOCATION)crystal spec -Dpreview_mt --order random

gresource:
Expand Down Expand Up @@ -54,3 +54,6 @@ uninstall:
rm -f $(PREFIX)/share/icons/hicolor/symbolic/apps/dev.geopjr.Collision-symbolic.svg
rm -rf $(PREFIX)$(LOCALE_LOCATION)/*/*/dev.geopjr.Collision.mo
gtk-update-icon-cache $(PREFIX)/share/icons/hicolor

validate-appstream:
appstreamcli validate ./data/dev.geopjr.Collision.metainfo.xml.in
3 changes: 2 additions & 1 deletion data/dev.geopjr.Collision.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "dev.geopjr.Collision",
"runtime": "org.gnome.Platform",
"runtime-version": "45",
"runtime-version": "45beta",
"sdk": "org.gnome.Sdk",
"command": "collision",
"finish-args": [
Expand Down Expand Up @@ -50,6 +50,7 @@
"cd lib/blake3/blake3c && make -f ../build/Makefile && cd ../../..",
"cd lib/gi-crystal && crystal build src/generator/main.cr && cd ../.. && mkdir ./bin && cp lib/gi-crystal/main ./bin/gi-crystal",
"./bin/gi-crystal",
"crystal spec -Dpreview_mt --order random || exit 1",
"COLLISION_LOCALE_LOCATION=\"/app/share/locale\" crystal build -Dpreview_mt ./src/collision.cr -Denable_gschema --release #--no-debug",
"msgfmt --xml --template data/dev.geopjr.Collision.metainfo.xml.in -d \"./po\" -o data/dev.geopjr.Collision.metainfo.xml",
"msgfmt --desktop --template data/dev.geopjr.Collision.desktop.in -d \"./po\" -o data/dev.geopjr.Collision.desktop",
Expand Down
2 changes: 1 addition & 1 deletion spec/hash_generator_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe Collision::Checksum do

safe_stop = Time.utc.to_unix_ms
loop do
break if Collision::CLIPBOARD_HASH.size == hashes.size || Time.utc.to_unix_ms - safe_stop > 3000
break if Collision::CLIPBOARD_HASH.size == hashes.size || Time.utc.to_unix_ms - safe_stop > Collision::CLIPBOARD_HASH.size * 1000
end

Collision::CLIPBOARD_HASH.each do |k, v|
Expand Down