diff --git a/.github/workflows/clean.yaml b/.github/workflows/clean.yaml index e4f64b53..b3778d7f 100644 --- a/.github/workflows/clean.yaml +++ b/.github/workflows/clean.yaml @@ -17,13 +17,7 @@ jobs: ci-gpg-private-key: ${{secrets.CI_GPG_PRIVATE_KEY}} github-gopass-ci-token: ${{secrets.GOPASS_CI_GITHUB_TOKEN}} - - run: | - sudo rm /etc/apt/sources.list.d/*.list - sudo apt update - sudo apt install --yes python3-wheel - - run: python3 -m pip install --user c2cciutils - - run: echo ~/.local/bin >> $GITHUB_PATH - name: Clean docker hub tags run: c2cciutils-clean diff --git a/c2cciutils/__init__.py b/c2cciutils/__init__.py index fc264f3b..7e608efa 100644 --- a/c2cciutils/__init__.py +++ b/c2cciutils/__init__.py @@ -178,16 +178,17 @@ def get_config(): if isinstance(config.get("checks", {}).get("required_workflows", {}), dict): merge( { - "clean.yaml": {"steps": [{"runs_re": ["c2cciutils-clean$"]}]}, + "clean.yaml": {"steps": [{"run_re": "c2cciutils-clean$"}]}, "audit.yaml": { - "steps": [{"runs_re": ["c2cciutils-audit --branch=.*$"], "env": "GITHUB_TOKEN"}], + "steps": [{"run_re": "c2cciutils-audit --branch=.*$", "env": ["GITHUB_TOKEN"]}], "strategy-fail-fast": False, }, }, config.get("checks", {}).get("required_workflows", {}), ) elif ( - config["checks"]["versions"].get("rebuild", False) + config["checks"]["versions"] + and config["checks"]["versions"].get("rebuild", False) and len(config["checks"]["versions"]["rebuild"].get("files", [])) == 0 ): config["checks"]["versions"]["rebuild"] = False @@ -196,7 +197,7 @@ def get_config(): required_workflows = { rebuild: { "noif": True, - "steps": [{"runs_re": [r"^c2cciutils-publish .*--type.*$"]}], + "steps": [{"run_re": r"^c2cciutils-publish .*--type.*$"}], "strategy-fail-fast": False, } for rebuild in config["checks"]["versions"]["rebuild"].get("files", ["rebuild.yaml"]) diff --git a/c2cciutils/checks.py b/c2cciutils/checks.py index 8d1bfef0..57f50600 100644 --- a/c2cciutils/checks.py +++ b/c2cciutils/checks.py @@ -2,7 +2,6 @@ import configparser import glob -import json import os import re import subprocess @@ -313,13 +312,13 @@ def required_workflows(config, full_config, args): ) success = False for step_conf in conf.get("steps", []): - run_re = re.compile(step_conf["run_re"]) if "run_re" in conf else None + run_re = re.compile(step_conf["run_re"]) if "run_re" in step_conf else None found = False for step in job["steps"]: current_ok = True if run_re is not None and run_re.match(step.get("run", "")) is None: current_ok = False - elif "env" in conf: + elif "env" in step_conf: # Verify that all the env specified in the config is present in the step of # the workflow conf_env = set(step_conf["env"]) @@ -334,8 +333,8 @@ def required_workflows(config, full_config, args): if not found: error( "required_workflows", - "The workflow '{}', job '{}' doesn't have the step for '{}'.".format( - filename, name, json.dumps(step_conf, indent=2) + "The workflow '{}', job '{}' doesn't have the step for:\n{}".format( + filename, name, yaml.dump(step_conf, Dumper=yaml.SafeDumper).strip() ), filename, ) @@ -621,8 +620,10 @@ def black(config, full_config, args): if not args.fix: cmd += ["--color", "--diff"] cmd.append("--") - cmd += _get_python_files(config.get("ignore_patterns_re", [])) - subprocess.check_call(cmd) + python_files = _get_python_files(config.get("ignore_patterns_re", [])) + cmd += python_files + if len(python_files) > 0: + subprocess.check_call(cmd) return True except subprocess.CalledProcessError: error( @@ -650,8 +651,10 @@ def isort(config, full_config, args): else: cmd += ["--check-only", "--diff"] cmd.append("--") - cmd += _get_python_files(config.get("ignore_patterns_re", [])) - subprocess.check_call(cmd) + python_files = _get_python_files(config.get("ignore_patterns_re", [])) + cmd += python_files + if len(python_files) > 0: + subprocess.check_call(cmd) return True except subprocess.CalledProcessError: error( diff --git a/c2cciutils/scripts/clean.py b/c2cciutils/scripts/clean.py index 9e0433d4..ab1913d8 100644 --- a/c2cciutils/scripts/clean.py +++ b/c2cciutils/scripts/clean.py @@ -46,8 +46,14 @@ def main() -> None: headers={"Content-Type": "application/json"}, data=json.dumps( { - "username": subprocess.check_output(["gopass", "show", "gs/ci/dockerhub/username"]).decode(), - "password": subprocess.check_output(["gopass", "show", "gs/ci/dockerhub/password"]).decode(), + "username": os.environ.get( + "DOCKERHUB_USERNAME", + subprocess.check_output(["gopass", "show", "gs/ci/dockerhub/username"]).decode(), + ), + "password": os.environ.get( + "DOCKERHUB_PASSWORD", + subprocess.check_output(["gopass", "show", "gs/ci/dockerhub/password"]).decode(), + ), } ), ).json()["token"]