-
Notifications
You must be signed in to change notification settings - Fork 3
exclude / exclusive arch test #64
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| name: Exclude/ExclusiveArch | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| run-python-script: | ||
| name: "${{ matrix.name }} specfiles" | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| include: | ||
| - source: tests/containers/c10s/Containerfile | ||
| env: tests/containers/fedora-branched/Containerfile | ||
| name: CentOS Stream 10 | ||
| target: centos-stream+epel-10 | ||
| failures: /src/tests/containers/c10s/exclude-failures.yaml | ||
| - source: tests/containers/fedora-branched/Containerfile | ||
| env: tests/containers/c10s/Containerfile | ||
| name: Fedora Stable | ||
| target: fedora-44 | ||
| failures: /src/tests/containers/fedora-branched/exclude-failures.yaml | ||
| steps: | ||
| - name: checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Extract Image ID from Containerfile | ||
| id: prep | ||
| run: | | ||
| IMAGE_NAME=$(grep -im1 '^FROM' ${{ matrix.source }} | awk '{print $2}' | xargs) | ||
| echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV | ||
| echo "Working with $IMAGE_NAME (z file: ${{ matrix.source }})" | ||
|
|
||
| - name: Pull and Extract files | ||
| run: | | ||
| set -x | ||
| mkdir -p ./extracted_artifacts | ||
| CONTAINER_ID=$(docker create ${{ env.IMAGE_NAME }}) | ||
| for i in rpm-specs rpm-specs-arches some-exclusion-found.txt; do | ||
| docker cp $CONTAINER_ID:/$i ./extracted_artifacts/ | ||
| done | ||
| docker rm $CONTAINER_ID | ||
|
|
||
| - name: Test Execution | ||
| run: | | ||
| set -x | ||
| IMAGE_NAME=$(grep -im1 '^FROM' ${{ matrix.env }} | awk '{print $2}' | xargs) | ||
| docker run --rm \ | ||
| -v ${{ github.workspace }}:/src:Z "$IMAGE_NAME" \ | ||
| /bin/bash -c "set -x ; dnf install -y python3-pyyaml ; /src/test_exclude_exclusive_arch.py ${{ matrix.target }} ${{ matrix.failures }}" |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| #! /usr/bin/python3 | ||
|
|
||
| """ | ||
| Run tests. | ||
| """ | ||
|
|
||
| import copy | ||
| import json | ||
| import logging | ||
| import os | ||
| import sys | ||
|
|
||
| import yaml | ||
|
|
||
| from norpm.macrofile import system_macro_registry | ||
|
|
||
| from norpm.overrides import override_macro_registry | ||
| from norpm.specfile import specfile_expand, ParserHooks | ||
|
|
||
|
|
||
| SPEC_DIR = "/src/extracted_artifacts/rpm-specs" | ||
| ARCHES_DIR = "/src/extracted_artifacts//rpm-specs-arches" | ||
| SPEC_LIST = "/src/extracted_artifacts/some-exclusion-found.txt" | ||
| OVERRIDES = "/distro-arch-specific.json" | ||
|
|
||
| LOG = logging.getLogger("arch-test") | ||
| LOG.setLevel(logging.INFO) | ||
| handler = logging.StreamHandler() | ||
| handler.setLevel(logging.INFO) | ||
| formatter = logging.Formatter( | ||
| "%(asctime)s | %(levelname)s | %(name)s | %(message)s" | ||
| ) | ||
| handler.setFormatter(formatter) | ||
| LOG.addHandler(handler) | ||
|
|
||
|
|
||
| class _TagHooks(ParserHooks): | ||
| """ Gather access to spec tags """ | ||
| def __init__(self): | ||
| self.tags = { | ||
| "exclusivearch": [], | ||
| "excludearch": [], | ||
| "buildarch": [], | ||
| } | ||
|
|
||
| def tag_found(self, name, value, _tag_raw): | ||
| """ | ||
| Parser hook that gathers the tags' values, if defined. | ||
| """ | ||
| if name not in self.tags: | ||
| return | ||
| LOG.debug("Appending: %s = %s", name, value) | ||
| self.tags[name].append(value) | ||
|
|
||
|
|
||
| def check_one(specfile, registry, expected_failures): | ||
| """ | ||
| Extract ExclusiveArch, ExcludeArch and BuildArch, and compare with | ||
| the given output. | ||
| """ | ||
|
|
||
| hooks = _TagHooks() | ||
| with open(os.path.join(SPEC_DIR, specfile), "r", encoding="utf8") as fd: | ||
| specfile_expand(fd.read(), registry, hooks) | ||
| with open(os.path.join(ARCHES_DIR, specfile + ".json"), "r", | ||
| encoding="utf8") as fdj: | ||
| exp = json.load(fdj) | ||
|
|
||
| retval = True | ||
| for key, value in exp.items(): | ||
| if key == 'error': | ||
| continue | ||
| if key not in hooks.tags: | ||
| LOG.error("%s failure on key=%s, expected_failure = %s, " | ||
| "found = NOTHING", specfile, key, value) | ||
| retval = False | ||
| continue | ||
|
|
||
| value = sorted(value) | ||
| found = sorted(hooks.tags[key]) | ||
| exp_failure = specfile in expected_failures and \ | ||
| key in expected_failures[specfile] | ||
|
|
||
| if value != found: | ||
| if exp_failure: | ||
| exp_fail = sorted(expected_failures[specfile][key]) | ||
| if exp_fail == found: | ||
| continue | ||
| LOG.error("%s failure on key=%s, expected_failure = %s," | ||
| "found = %s", specfile, key, exp_fail, found) | ||
| retval = False | ||
| continue | ||
|
|
||
| LOG.error("%s failure on key=%s, expected = %s, found = %s", | ||
| specfile, key, value, found) | ||
| retval = False | ||
| elif exp_failure: | ||
| LOG.error("Unexpected pass on %s key=%s", specfile, key) | ||
| retval = False | ||
|
|
||
| return retval | ||
|
|
||
|
|
||
| def process_exclusions(filepath): | ||
| """ | ||
| Go through all the specfiles with ExcludeArch/ExclusiveArch statements. | ||
| """ | ||
| retval = 0 | ||
|
|
||
| if not os.path.exists(filepath): | ||
| LOG.fatal("File %s not found", filepath) | ||
| sys.exit(1) | ||
|
|
||
| destination = None | ||
| registry = system_macro_registry() | ||
| if len(sys.argv) < 3: | ||
| LOG.fatal("missing arguments") | ||
| sys.exit(1) | ||
|
|
||
| destination = sys.argv[1] | ||
| registry = override_macro_registry(registry, OVERRIDES, destination) | ||
| with open(sys.argv[2], "r", encoding="utf-8") as fd: | ||
| expected_failures = yaml.safe_load(fd) | ||
|
|
||
| try: | ||
| with open(filepath, 'r', encoding='utf-8') as f: | ||
| for line in f: | ||
| filename = line.strip() | ||
| LOG.info("Checking %s", filename) | ||
| if not filename: | ||
| continue | ||
| if not check_one(filename, copy.deepcopy(registry), | ||
| expected_failures): | ||
| retval = 1 | ||
|
|
||
| except Exception: # pylint: disable=broad-exception-caught | ||
| LOG.exception("Error when reading files.") | ||
| sys.exit(1) | ||
|
|
||
| return retval | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(process_exclusions(SPEC_LIST)) | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| FROM quay.io/redhat-user-workloads/fedora-copr-tenant/norpm-testing-image:latest-el10@sha256:5cfa3538ad66710a7d8944ffe59dda50f1a67a2b6d561ef891e1133b15707055 |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| grafana-pcp.spec: | ||
| exclusivearch: | ||
| - '%{lua: go_arches = {}' | ||
| grafana.spec: | ||
| exclusivearch: | ||
| - '%{lua: go_arches = {}' |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| FROM quay.io/redhat-user-workloads/fedora-copr-tenant/norpm-testing-image:latest@sha256:b2befe4921b00dd6fa814bc232f4e882003929da48f52a93ebc212d5a1fc2b9a |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| blah.spec: | ||
| exclusivearch: | ||
| - 'x86_64 aarch64 ppc64le s390x riscv64' | ||
| colorscad.spec: | ||
| excludearch: | ||
| - 'i386 i486 i586 i686 pentium3 pentium4 athlon geode' | ||
| edwin-fonts.spec: | ||
| buildarch: [] | ||
| grafana-pcp.spec: | ||
| exclusivearch: | ||
| - '%{lua: go_arches = {}' | ||
| grafana.spec: | ||
| exclusivearch: | ||
| - '%{lua: go_arches = {}' | ||
| kdepim-addons.spec: | ||
| exclusivearch: | ||
| - "%(echo %{qt6_qtwebengine_arches} | sed -e 's/i686//g')" | ||
| marcsabatella-campania-fonts.spec: | ||
| buildarch: [] | ||
| nodejs-cjs-module-lexer.spec: | ||
| exclusivearch: | ||
| - '%{lua:' | ||
| sigul.spec: | ||
| excludearch: [] | ||
| steinberg-bravura-fonts.spec: | ||
| buildarch: [] | ||
| steinberg-petaluma-fonts.spec: | ||
| buildarch: [] | ||
| terminus-fonts.spec: | ||
| buildarch: [] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.