Skip to content

Commit ec6755d

Browse files
authored
Merge branch 'flathub-infra:master' into master
2 parents 71a3813 + afacd1f commit ec6755d

File tree

21 files changed

+342
-65
lines changed

21 files changed

+342
-65
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: master
66
pull_request:
77
branches: master
8+
types: [opened, edited, reopened, synchronize, ready_for_review]
89
workflow_dispatch:
910
# Keep an active cache
1011
schedule:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Janitor stale exceptions
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * 1,5'
7+
8+
jobs:
9+
janitor:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
timeout-minutes: 20
15+
steps:
16+
# 4.2.2
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
18+
with:
19+
persist-credentials: false
20+
21+
- name: Purge exceptions
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
run: python utils/validator.py --purge-from-issue 750
25+
26+
- name: Validate
27+
run: python utils/validator.py
28+
29+
- name: Check for changes
30+
id: diff
31+
run: |
32+
FILE="flatpak_builder_lint/staticfiles/exceptions.json"
33+
if git diff --quiet -- "$FILE"; then
34+
echo "changed=false" >> $GITHUB_OUTPUT
35+
else
36+
echo "changed=true" >> $GITHUB_OUTPUT
37+
fi
38+
39+
- name: Create pull request
40+
if: ${{ success() && steps.diff.outputs.changed == 'true' }}
41+
# 7.0.8
42+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
43+
with:
44+
token: ${{ secrets.GITHUB_TOKEN }}
45+
branch-suffix: "random"
46+
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
47+
commit-message: "(Automated) Purge stale exceptions"
48+
title: "(Automated) Purge stale exceptions"
49+
body: "(Automated) Purge stale exceptions"
50+
delete-branch: true
51+
sign-commits: true
52+
draft: always-true

.github/workflows/label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Label pull requests
55

66
on:
77
pull_request_target:
8-
types: [opened, edited, reopened, synchronize]
8+
types: [opened, edited, reopened, synchronize, ready_for_review]
99
branches:
1010
- master
1111
paths:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ options:
304304
--ref Override the primary ref detection with this ref
305305
--gha-format Use GitHub Actions annotations in CI
306306
--janitor-exceptions Enable reporting of stale exceptions to linter repository
307+
--debug Enable debug logging
307308
308309
Please report any issues at https://github.com/flathub-infra/flatpak-builder-lint
309310
```

flatpak_builder_lint/checks/appid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import re
3+
from collections.abc import Mapping
34
from typing import Any
45

56
from .. import builddir, config, domainutils
@@ -84,7 +85,7 @@ def _validate(self, appid: str | None, is_extension: bool) -> None:
8485
message += f" | {resp}"
8586
self.info.add(message)
8687

87-
def check_manifest(self, manifest: dict[str, Any]) -> None:
88+
def check_manifest(self, manifest: Mapping[str, Any]) -> None:
8889
appid = manifest.get("id")
8990
is_extension = manifest.get("build-extension", False)
9091

flatpak_builder_lint/checks/elfarch.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import glob
2+
import logging
23
import os
34
import struct
45
import tempfile
56

67
from .. import builddir, ostree
78
from . import Check
89

10+
logger = logging.getLogger(__name__)
11+
912

1013
def is_elf(fname: str) -> bool:
1114
if not os.path.isfile(fname):
1215
return False
1316
try:
1417
with open(fname, "br") as f:
1518
return f.read(4) == b"\x7fELF"
16-
except OSError:
19+
except OSError as e:
20+
logger.debug("Failed to read file %s: %s: %s", fname, type(e).__name__, e)
1721
return False
1822

1923

@@ -33,8 +37,12 @@ def get_elf_arch(fname: str) -> str | None:
3337
0xF3: "riscv64",
3438
}
3539
return arch_map.get(e_machine)
36-
except struct.error:
37-
pass
40+
except struct.error as e:
41+
logger.debug(
42+
"Failed to unpack ELF architecture from %s: %s: %s", fname, type(e).__name__, e
43+
)
44+
except OSError as e:
45+
logger.debug("Failed to read ELF file %s: %s: %s", fname, type(e).__name__, e)
3846
return None
3947

4048

flatpak_builder_lint/checks/eolruntime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import tempfile
2+
from collections.abc import Mapping
23
from typing import Any
34

45
from .. import builddir, domainutils, ostree
@@ -14,7 +15,7 @@ def _validate(self, runtime_ref: str) -> None:
1415
if decomp_ref in eols_runtimes:
1516
self.warnings.add(f"runtime-is-eol-{splits[0]}-{splits[2]}")
1617

17-
def check_manifest(self, manifest: dict[str, Any]) -> None:
18+
def check_manifest(self, manifest: Mapping[str, Any]) -> None:
1819
runtime_id = manifest.get("runtime")
1920
runtime_br = manifest.get("runtime-version")
2021

flatpak_builder_lint/checks/finish_args.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import tempfile
33
from collections import defaultdict
4+
from collections.abc import Mapping
45
from typing import Any
56

67
import gi
@@ -505,7 +506,7 @@ def _validate(self, appid: str | None, finish_args: dict[str, set[str]]) -> None
505506
+ " full system or session bus"
506507
)
507508

508-
def check_manifest(self, manifest: dict[str, Any]) -> None:
509+
def check_manifest(self, manifest: Mapping[str, Any]) -> None:
509510
appid = manifest.get("id")
510511

511512
is_baseapp = bool(

flatpak_builder_lint/checks/flathub_json.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import tempfile
2+
from collections.abc import Mapping
23
from typing import Any
34

45
from .. import builddir, config, ostree
@@ -54,7 +55,7 @@ def _validate(
5455
):
5556
self.errors.add("flathub-json-excluded-all-arches")
5657

57-
def check_manifest(self, manifest: dict[str, Any]) -> None:
58+
def check_manifest(self, manifest: Mapping[str, Any]) -> None:
5859
flathub_json = manifest.get("x-flathub")
5960
appid = manifest.get("id")
6061
if not (flathub_json and appid):

flatpak_builder_lint/checks/jsonschema.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import importlib.resources
22
import json
3+
from collections.abc import Mapping
34
from typing import Any
45

56
import jsonschema
@@ -10,7 +11,7 @@
1011

1112

1213
class JSONSchemaCheck(Check):
13-
def check_manifest(self, manifest: dict[str, Any]) -> None:
14+
def check_manifest(self, manifest: Mapping[str, Any]) -> None:
1415
with (
1516
importlib.resources.files(staticfiles)
1617
.joinpath("flatpak-manifest.schema.json")
@@ -19,7 +20,7 @@ def check_manifest(self, manifest: dict[str, Any]) -> None:
1920
schema = json.load(f)
2021

2122
try:
22-
jsonschema.validate(manifest, schema)
23+
jsonschema.validate(dict(manifest), schema)
2324
except jsonschema.exceptions.SchemaError:
2425
self.errors.add("jsonschema-schema-error")
2526
except jsonschema.exceptions.ValidationError as exc:

0 commit comments

Comments
 (0)