Parse required-flatpak and enforce a minimum version for new metadata #1697
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: master | |
pull_request: | |
branches: master | |
workflow_dispatch: | |
env: | |
# Match with fdsdk runtime | |
PYTHON_VERSION: "3.12" | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
if: always() | |
permissions: | |
pull-requests: read | |
outputs: | |
src: ${{ steps.filter.outputs.src }} | |
docker: ${{ steps.filter.outputs.docker }} | |
exceptions: ${{ steps.filter.outputs.exceptions }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup path filters | |
uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
shared: &shared | |
- '.github/**' | |
- 'docker/**' | |
- 'flatpak_builder_lint/!(staticfiles/**)/**' | |
- 'flatpak_builder_lint/staticfiles/flatpak-manifest.schema.json' | |
- 'flatpak_builder_lint/staticfiles/*.py' | |
- 'poetry.lock' | |
- 'pyproject.toml' | |
exceptions: | |
- 'flatpak_builder_lint/staticfiles/exceptions.json' | |
src: | |
- *shared | |
- 'tests/**' | |
- 'utils/**' | |
docker: | |
- *shared | |
exceptions: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
needs: | |
- changes | |
if: ${{ needs.changes.outputs.exceptions == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Validate exceptions.json | |
run: python3 utils/validator.py | |
ci: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
platform: amd64 | |
- os: ubuntu-22.04-arm | |
platform: arm64 | |
runs-on: ${{matrix.os}} | |
timeout-minutes: 30 | |
concurrency: | |
group: ci-${{ matrix.platform }} | |
cancel-in-progress: true | |
needs: | |
- changes | |
if: ${{ needs.changes.outputs.src == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Validate exceptions.json | |
run: python3 utils/validator.py | |
- name: Set up dependencies | |
run: | | |
sudo add-apt-repository ppa:flatpak/stable | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends jq flatpak \ | |
desktop-file-utils elfutils flatpak-builder curl \ | |
dbus-daemon libgirepository1.0-dev \ | |
gir1.2-ostree-1.0 gzip xmlstarlet libcairo2-dev \ | |
gir1.2-appstream-1.0 | |
- name: Setup Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
sudo ln -s /github/home/.local/bin/poetry /usr/bin/poetry | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-${{ matrix.platform }}-ci-poetry-${{ hashFiles('poetry.lock') }} | |
restore-keys: ${{ runner.os }}-${{ matrix.platform }}-ci-poetry- | |
- name: Install python dependencies | |
run: | | |
poetry install | |
- name: Check code formatting | |
run: poetry run ruff format --check . | |
- name: Lint | |
run: poetry run ruff check --output-format=github . | |
- name: Check python types | |
run: poetry run mypy . | |
- name: Allow file:// clones with git>=2.38.1 | |
run: | | |
git config --global protocol.file.allow always | |
- name: Set up flathub remote | |
run: | | |
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo | |
flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo | |
- name: Prepare org.flatpak.Builder | |
run: | | |
git clone --depth=1 --branch master --recursive --single-branch https://github.com/flathub/org.flatpak.Builder.git build/org.flatpak.Builder | |
cd build && python3 ../docker/rewrite-manifest.py | |
cd org.flatpak.Builder | |
cp -vf ../../docker/flatpak-builder-lint-deps.json . | |
cp -vf ../../tests/python3-pytest.json . | |
jq '.modules |= map(if . == "flatpak-builder-lint-deps.json" then . , "python3-pytest.json" else . end)' org.flatpak.Builder.json >> org.flatpak.Builder-modified.json | |
mv -vf org.flatpak.Builder-modified.json org.flatpak.Builder.json | |
- name: Prepare for hashing | |
run: | | |
flatpak-builder --show-manifest build/org.flatpak.Builder/org.flatpak.Builder.json >> build/org.flatpak.Builder/org.flatpak.Builder-cache.json | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/cache/.flatpak-builder | |
key: ${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-${{ hashFiles('build/org.flatpak.Builder/org.flatpak.Builder-cache.json') }} | |
restore-keys: ${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder- | |
- name: Set Flatpak arch | |
run: | | |
if [ "${{ matrix.platform }}" = "amd64" ]; then | |
echo "FP_ARCH=x86_64" >> $GITHUB_ENV | |
elif [ "${{ matrix.platform }}" = "arm64" ]; then | |
echo "FP_ARCH=aarch64" >> $GITHUB_ENV | |
else | |
echo "Unsupported platform: ${{ matrix.platform }}" | |
exit 1 | |
fi | |
- name: Build and test org.flatpak.Builder | |
run: | | |
cd build/org.flatpak.Builder | |
flatpak-builder --verbose --user --force-clean \ | |
--arch=${{ env.FP_ARCH }} \ | |
--state-dir="$GITHUB_WORKSPACE/cache/.flatpak-builder" \ | |
--install-deps-from=flathub --default-branch=localtest \ | |
--ccache --keep-build-dirs --install builddir \ | |
org.flatpak.Builder.json | |
flatpak run org.flatpak.Builder//localtest --version | |
- name: Run test suite | |
run: flatpak run --command=pytest org.flatpak.Builder//localtest -vvv tests | |
- name: Run Flatmanager checks | |
run: bash -c tests/flatmanager.sh | |
- name: Sanity check on a GUI application | |
run: | | |
cd tests/repo/min_success_metadata/gui-app | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions manifest org.flathub.gui.yaml | |
dbus-run-session flatpak run org.flatpak.Builder --verbose --user --force-clean \ | |
--state-dir="$GITHUB_WORKSPACE/cache/.flatpak-builder" --repo=repo \ | |
--arch=${{ env.FP_ARCH }} \ | |
--mirror-screenshots-url=https://dl.flathub.org/media \ | |
--install-deps-from=flathub --ccache builddir org.flathub.gui.yaml | |
mkdir -p builddir/files/share/app-info/media | |
ostree commit --repo=repo --canonical-permissions --branch=screenshots/${{ env.FP_ARCH }} builddir/files/share/app-info/media | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions builddir builddir | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions repo repo | |
- name: Sanity check on a console application | |
run: | | |
cd tests/repo/min_success_metadata/console-app | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions manifest org.flathub.cli.yaml | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest appstream org.flathub.cli.metainfo.xml | |
dbus-run-session flatpak run org.flatpak.Builder --verbose --user --force-clean \ | |
--arch=${{ env.FP_ARCH }} \ | |
--state-dir="$GITHUB_WORKSPACE/cache/.flatpak-builder" --repo=repo \ | |
--install-deps-from=flathub --ccache builddir org.flathub.cli.yaml | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions builddir builddir | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions repo repo | |
- name: Sanity check on a baseapp | |
run: | | |
git clone --depth=1 --recursive --single-branch https://github.com/flathub/com.system76.Cosmic.BaseApp.git com.system76.Cosmic.BaseApp | |
cd com.system76.Cosmic.BaseApp | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions manifest com.system76.Cosmic.BaseApp.json | |
dbus-run-session flatpak run org.flatpak.Builder --verbose --user --force-clean \ | |
--arch=${{ env.FP_ARCH }} \ | |
--repo=repo --state-dir="$GITHUB_WORKSPACE/cache/.flatpak-builder" \ | |
--install-deps-from=flathub --ccache builddir com.system76.Cosmic.BaseApp.json | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions builddir builddir | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions repo repo | |
- name: Sanity check on an extension | |
run: | | |
git clone --depth=1 --recursive --single-branch https://github.com/flathub/org.freedesktop.LinuxAudio.Plugins.SoSynthLV2.git org.freedesktop.LinuxAudio.Plugins.SoSynthLV2 | |
cd org.freedesktop.LinuxAudio.Plugins.SoSynthLV2 | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions manifest org.freedesktop.LinuxAudio.Plugins.SoSynthLV2.json | |
dbus-run-session flatpak run org.flatpak.Builder --verbose --user --force-clean \ | |
--arch=${{ env.FP_ARCH }} \ | |
--repo=repo --state-dir="$GITHUB_WORKSPACE/cache/.flatpak-builder" \ | |
--install-deps-from=flathub --ccache builddir org.freedesktop.LinuxAudio.Plugins.SoSynthLV2.json | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions builddir builddir | |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder//localtest --exceptions repo repo | |
docker-call: | |
permissions: | |
packages: write | |
needs: | |
- changes | |
- ci | |
if: ${{ needs.changes.outputs.docker == 'true' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }} | |
uses: ./.github/workflows/docker.yml | |
secrets: inherit | |
docker-test: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
platform: amd64 | |
- os: ubuntu-22.04-arm | |
platform: arm64 | |
runs-on: ${{matrix.os}} | |
timeout-minutes: 30 | |
concurrency: | |
group: docker_test-${{ matrix.platform }} | |
cancel-in-progress: true | |
needs: | |
- changes | |
if: ${{ needs.changes.outputs.src == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build the test image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: tests/Dockerfile | |
push: false | |
provenance: false | |
load: true | |
no-cache-filters: image | |
tags: linter:dev | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Run tests with the test docker image | |
run: docker run linter:dev pytest -vvv |