NSF-Swift / satellite-overhead

An open-source tool for calculating satellite interference to radio astronomy observations.
https://pypi.org/project/sopp/
GNU Affero General Public License v3.0
0 stars 2 forks source link

Refactor CI and add CD #101

Closed 0xeb-bp closed 10 months ago

0xeb-bp commented 10 months ago

This PR adds CD via GitHub Actions and slightly refactors the old tests into a new GitHub Action ci.yml.

.github/workflows/ci.yml replaces the old .github/workflows/run_tests.yml. We now will run the tests on a push to main in addition to running tests on pull requests. The tests are now being invoked through our build system hatch. This allows us to consolidate testing dependencies into one location, hatch.toml. Tests can be invoked locally with hatch run test:test, this will run tests locally for our supported python versions.

CD has been added in .github/workflows/cd.yml. This action will be ran after tests pass on push to main. The action uses hatch to build the packages. python-semantic-version is being used to automatically do the versioning, create a changelog, create release notes and create a release in GitHub Releases.

python-semantic-version automatically determines the next version number by parsing commit messages. The default configuration is shown below, however we can customize if desired:

[tool.semantic_release.commit_parser_options]
allowed_tags = [
    "build",
    "chore",
    "ci",
    "docs",
    "feat",
    "fix",
    "perf",
    "style",
    "refactor",
    "test",
]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]

An example would be git commit -m "fix: resolve some error." This would be cause a semantic version patch increase e.g. 0.1.0 -> 0.1.1. Commits that do not start with "fix:", "feat:" or "perf:" do not cause a version increase. Using the other tags, for example, "build:" will be add the commit message to the changelog and release notes.

The general CD flow is:

+---------------+       +--------------+      +--------+      +-------+
| Push to Main  |       |   Run Tests  |      | Tests  |      |  End  |
|               |------>|              |----->| Fail   |----->|       |<-+
+---------------+       +--------------+      +--------+      +-------+  |
                               |                                   ^     |
                               v                                   |     |
                        +-------------+                            |     |
                        |  Tests Pass |                            |     |
                        |             |                            |     |
                        +-------------+                            |     |
                               |                                   |     |
                               v                                   |     |
                        +-------------+                            |     |
                        |  Start CD   |                            |     |
                        |             |                            |     |
                        +-------------+                            |     |
                               |                                   |     |
                               v                                   |     |
                   +-----------------------+      +-------------------+  |
                   | semantic-release      |      | No Release Needed |  |
                   | parse commit messages |----> |                   |  |
                   +-----------------------+      +-------------------+  |
                               |                                         |
                               v                                         |
                      +-----------------+                                |
                      | Release Needed  |                                |
                      |                 |                                |
                      +-----------------+                                |
                               |                                         |
                               v                                         |
                   +-------------------------+                           |
                   | - Build Package         |                           |
                   | - Create Changelog      |                           |
                   | - Create Release Notes  |                           |
                   | - Create GitHub Release |                           |
                   | - Push to PyPI          |---------------------------+
                   +-------------------------+

Finally, the readme was updated to have badges for passing and failing CI/CD.