Skip to main content

GitHub Actions Workflow Differ

Project description

gawd - GitHub Actions Workflow Differ

Tests License: LGPL v3 PyPI Commits

gawd stands for GitHub Actions Workflow Differ. It is a Python library and command-line tool that computes all changes (i.e., diffs) between two GitHub Actions workflow files. Given a pair of workflow files as input, and taking the specific syntax of GitHub Actions into account, gawd reports on the items that were added and removed, as well on items that were moved, renamed or changed based on their similarity.

Table of contents

Installation

gawd can be used in two ways: as a command-line tool and as a reusable Python library.

You can use pip install gawd to install the latest available version from PyPI. Pre-releases are available from the main branch on GitHub and can be installed with pip install git+https://github.com/pooya-rostami/gawd.

Usage

As a command-line tool

After installation, the gawd command-line tool should be available in your shell. Otherwise, you can call it using python -m gawd.

usage: gawd [-h] [--threshold X] [--position-weight X] [--job-name-weight X] [--short] first second

gawd is a GitHub Actions Workflow Differ

positional arguments:
  first                 path to first workflow file
  second                path to second workflow file

options:
  -h, --help            show this help message and exit
  --threshold X, -t X   distance threshold to map items, higher values favours "changed", lower values favours
                        "added" and "removed" (default is 0.5)
  --position-weight X, -p X
                        weight of item positions when comparing sequences (default is 0.2)
  --job-name-weight X, -j X
                        weight of job names when comparing jobs (default is 0.2)
  --short, -s           limit the output of values to a few characters

The following example shows the output of the command line version of gawd when applied to compute the changes made to the workflow file main.yml which can be seen in this commit.

>>> gawd old_main.yaml new_main.yaml --short
changed jobs.build-linux-clangpdb-gcc5.steps[1].run from "'sudo apt-get update (...) UB_PATH\n'" to "'sudo apt-get update (...) UB_PATH\n'"
renamed jobs.build-linux-clang38 to jobs.build-linux-clangdwarf
changed jobs.build-linux-clang38.name from "'Build Linux CLANG38'" to "'Build Linux CLANGDWARF'"
changed jobs.build-linux-clang38.env.TOOLCHAINS from "'CLANG38'" to "'CLANGDWARF'"
changed jobs.build-linux-clang38.steps[6].with.name from "'Linux CLANG38 Artifacts'" to "'Linux CLANGDWARF Artifacts'"

As an importable library

gawd comes with two functions to compare workflow files, namely diff_workflow_files and diff_workflows. The former accepts the paths to two workflow files, loads them and returns the output of diff_workflows. The latter accepts two workflows as Python dictionaries (e.g., loaded with ruamel.yaml) and returns a list of 5-tuples (kind, old_path, old_value, new_path, new_value).

The kind component is one of added, removed, changed, moved, renamed and indicates the kind of change. old_path and new_path correspond to a dotted notation indicating where the change occurred, while old_value and new_value correspond to the previous and new values, respectively. Notice that old_path and old_value are set to None in case of an "added" change. Similarly, new_path and old_path are None in case of a "removed" change.

Similarly to the extra parameters that can be provided to the CLI tool, the gawd module exposes THRESHOLD, POSITION_WEIGHT and JOB_NAME_WEIGHT.

The following example shows the output of the imported library version of gawd for the changes made to the workflow file main.yml in this commit.

>>> from gawd import diff_workflow_files
>>> old_workflow_path = ...
>>> new_workflow_path = ...
>>> diff_workflow_files(old_workflow_path, new_workflow_path)
[('changed', 'jobs.build-linux-clangpdb-gcc5.steps[1].run', 'sudo apt-get update\nsudo apt-get install nasm ...', 'jobs.build-linux-clangpdb-gcc5.steps[1].run', 'sudo apt-get update\nsudo apt-get install nasm ...'),
('renamed', 'jobs.build-linux-clang38', {'name': 'Build Linux CLANG38', ...}, 'jobs.build-linux-clangdwarf', {'name': 'Build Linux CLANGDWARF', ...}),
('changed', 'jobs.build-linux-clang38.name', 'Build Linux CLANG38', 'jobs.build-linux-clangdwarf.name', 'Build Linux CLANGDWARF'),
('changed', 'jobs.build-linux-clang38.env.TOOLCHAINS', 'CLANG38', 'jobs.build-linux-clangdwarf.env.TOOLCHAINS', 'CLANGDWARF'),
('changed', 'jobs.build-linux-clang38.steps[6].with.name', 'Linux CLANG38 Artifacts', 'jobs.build-linux-clangdwarf.steps[6].with.name', 'Linux CLANGDWARF Artifacts')]

Contributions

Contributions are very welcome! Feel free to report bugs or suggest new features using GitHub issues and/or pull requests.

License

Distributed under GNU Lesser General Public License v3.

You can refer to this library using:

@software{gawd,
  author = {{Rostami Mazrae}, Pooya and Decan, Alexandre},
  title = {gawd: GitHub Actions Workflow Differ},
  url = {https://github.com/pooya-rostami/gawd},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gawd-1.0.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gawd-1.0.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file gawd-1.0.0.tar.gz.

File metadata

  • Download URL: gawd-1.0.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for gawd-1.0.0.tar.gz
Algorithm Hash digest
SHA256 29d07f8f8677d50259c3682d72fa99677f25c39979b950295b23e2d7a24c44ea
MD5 0fa7c257faa5ec28e6dee5ef117fbb3a
BLAKE2b-256 b54a1d13e6985b0bfaa3aa95e21360187890db637456a5a348dade95d59fe5ea

See more details on using hashes here.

File details

Details for the file gawd-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gawd-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for gawd-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c564df4e0e4d4027846feabc8a396c7033aac6cf4c6314257bb5d5b156e8424
MD5 7d39504a08922bc93b57bc68663fdaa0
BLAKE2b-256 7acc18ddafa827eb4b59a54c3d6c56727c0fc76eb86d271a71a5e9f98072339a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page