Compare commits

...

171 Commits

Author SHA1 Message Date
umarcor
adef08d3bd v0.4.6 2023-02-26 17:44:46 +01:00
umarcor
191a6471ed releaser: fix creating a release with no assets 2023-02-26 15:42:43 +01:00
Patrick Lehmann
3ae8451cc0 Merge pull request #61 from antoineco/fix-eol
Append EOL after value in GITHUB_STATE
2023-01-27 20:05:35 +01:00
Antoine Cotten
f4951ec52e fix: append EOL after value in GITHUB_STATE 2023-01-27 18:49:49 +01:00
Unai Martinez-Corral
cc576ce25a v0.4.5 (#58) 2022-11-08 02:24:19 +00:00
Unai Martinez-Corral
decf16ff8f with-post-step: update copyright header 2022-11-08 03:21:27 +01:00
Unai Martinez-Corral
9faa1459c9 with-post-step: use option 'shell: true' by default and do not split args
This fixes a breaking change introduced in #46.
'exec' executes commands on the shell by default, while 'spawn' does not.
2022-11-08 03:15:19 +01:00
Unai Martinez-Corral
eb1108c0f0 v0.4.4 (#57) 2022-11-08 00:04:43 +00:00
Unai Martinez-Corral
47ef801713 update codecov/codecov-action to v3 2022-11-07 23:41:59 +00:00
Unai Martinez-Corral
27272d362c update codecov/codecov-action to v2 2022-11-07 23:29:06 +00:00
Unai Martinez-Corral
b12b2d65be update geekyeggo/delete-artifact to v2 2022-11-07 23:25:55 +00:00
Unai Martinez-Corral
bc41308f30 update actions/download-artifact to v3 2022-11-07 22:52:28 +00:00
Unai Martinez-Corral
bbcfd70907 update actions/upload-artifact to v3 2022-11-07 22:52:28 +00:00
Unai Martinez-Corral
c2c2516ec8 update actions/setup-python to v4 2022-11-07 22:52:28 +00:00
Unai Martinez-Corral
57a0827b14 update actions/checkout to v3 2022-11-07 22:52:28 +00:00
Unai Martinez-Corral
17bc23954a set-output is deprecated
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-11-07 22:52:28 +00:00
Unai Martinez-Corral
97fd0e5927 with-post-step: save-state is deprecated
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-11-07 22:52:09 +00:00
Unai Martinez-Corral
60dd89651a with-post-step: use Node.js 16 instead of Node.js 12
https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
2022-11-07 22:14:56 +00:00
Patrick Lehmann
8d0bd87229 Merge remote-tracking branch 'github/main' into dev 2022-10-25 22:42:37 +02:00
Unai Martinez-Corral
31f02bb75b releaser: sort globbed files (#52) 2022-07-20 12:46:13 +01:00
Boyd Kane
c11c7295f6 Sort globbed files for releases
This change simply sorts the list of files after the glob has been resolved. This is useful because these files are often destined for a release, and having to scroll through hundreds of files which aren't sorted is *painful*.

I'm happy to convert this into an option that can be specified in the yaml if you'd prefer?
2022-07-16 13:56:14 +02:00
Patrick Lehmann
09205eccb8 Added also @umarcor to assignees and reviewers for dependabot. 2022-07-14 11:19:37 +02:00
Patrick Lehmann
72f3e4c148 Python version in MinGW64 was bumped from 3.9 to 3.10. 2022-07-14 11:14:06 +02:00
umarcor
d340857eb3 merge main into dev 2022-07-06 17:42:33 +02:00
Unai Martinez-Corral
c8b411bb64 ci: add dependabot configuration file (#43) 2022-06-28 12:56:07 +01:00
Unai Martinez-Corral
895a8764b3 with-post-step: print 'live' logs from subprocess (#46) 2022-06-28 12:54:13 +01:00
dogbert911
2305ab2027 Fix linter 2022-03-31 22:02:40 +03:00
dogbert911
37a055c776 'online' logs from subprocess 2022-03-31 21:25:35 +03:00
umarcor
f0ad308283 v0.4.3 2022-03-02 23:50:16 +01:00
umarcor
562b28ee34 readme: add light screenshot (#42) 2022-03-02 23:49:41 +01:00
Patrick Lehmann
00c43821dd Add dependabot to check for GH action updates. 2022-03-02 18:54:12 +01:00
Unai Martinez-Corral
8cfda1f21a Package: support with and without isolation mode (#39)
# New Features

* Added a 3rd overload for parameter `requirements` in job template `Package`:
  1. When `requirements` is empty  
     → build Python package with `build` in isolation mode. (old behavior)
  1. When `requirements` is `no-isolation`  
     → build Python package with `build` in non-isolation mode. (intended behavior since last release, but it had side-effects)
  1. When `requirements` is any other string  
     → build Python package with `setuptools` using the given `requirements.txt` file to install build dependencies.

# Bug Fixes

* Restore old behavior (run `build` in isolation mode using `venv`).
2022-03-01 22:32:13 +00:00
Patrick Lehmann
457870d760 Support with and without isolation mode. 2022-02-27 17:33:44 +01:00
umarcor
df3d45363b v0.4.2 2022-02-22 21:47:38 +01:00
Unai Martinez-Corral
6ba0204549 Build packages in no-isolation mode (#38)
# Changes

* Build Python packages in `no-isolation` mode.
* Updated year in copyright to 2022.
2022-02-22 21:44:41 +01:00
Patrick Lehmann
7a7976677e Run build in no-isolation mode. 2022-02-22 21:28:34 +01:00
Patrick Lehmann
4579381b78 Bumped year to 2022. 2022-02-22 21:28:08 +01:00
umarcor
14ac6c6386 v0.4.1 2022-01-17 01:30:38 +01:00
Patrick Lehmann
18357ec213 UnitTesting: add options 'pacboy' and 'mingw_requirements' 2022-01-17 01:29:16 +01:00
umarcor
4220a50041 UnitTesting: add options 'pacboy' and 'mingw_requirements' 2022-01-17 00:07:56 +01:00
umarcor
d8264eab8a v0.4.0 2022-01-09 20:58:08 +01:00
Patrick Lehmann
b9d3839abb Extend Unit Tests to multiple systems (ubuntu, windows, msys2 and macos) 2022-01-09 20:56:58 +01:00
umarcor
997d548e60 Parameters: update py36 warning, add py311 notice 2022-01-09 20:39:36 +01:00
umarcor
83cd572694 UnitTesting: update description of input 'jobs' 2022-01-09 20:39:12 +01:00
Unai Martinez-Corral
68a446b9b6 UnitTesting: workarounds for MSYS2-MinGW64 (pacman) (#35) 2022-01-09 20:19:56 +01:00
Patrick Lehmann
43f0b79e88 UnitTesting/msys2: install system packages through 'pacboy'; refactor 2022-01-09 20:05:51 +01:00
umarcor
b3d8a9c5ec UnitTesting: refactor 2022-01-09 20:02:09 +01:00
umarcor
edb6ca364e UnitTesting/msys2: install system packages through 'pacboy' 2022-01-09 20:02:09 +01:00
Patrick Lehmann
e00f5cf53d Added MSYS2-MinGW64 specific code. 2022-01-09 20:00:36 +01:00
Unai Martinez-Corral
0da8c5a5c5 UnitTesting: install wheel; support py3.11; fix scripting for Windows (PowerShell commands) (#34) 2022-01-09 19:34:23 +01:00
Patrick Lehmann
c9bee6fe65 Require wheel to be installed before installing requirements. 2022-01-09 18:44:06 +01:00
Patrick Lehmann
94bb01d586 Renamed Python 3.11 version. 2022-01-09 18:25:02 +01:00
Patrick Lehmann
0fdef33cb4 Improved PoSh code. 2022-01-09 18:10:42 +01:00
Patrick Lehmann
e1f7599d79 Added Python 3.11 (currently RC). 2022-01-09 18:07:29 +01:00
Patrick Lehmann
dad5e71bfe Added PowerShell code. 2022-01-09 17:39:16 +01:00
umarcor
60d77c2292 Parameters: support system 'msys2' (MINGW64); update UnitTesting accordingly 2022-01-07 01:40:42 +01:00
umarcor
3f489f0bed Parameters: add option 'system_list'; UnitTesting now requires field 'system' in the matrix 2022-01-07 00:39:14 +01:00
umarcor
26afa43fa4 Parameters: remove 3.6 from default python_version_list 2022-01-07 00:37:22 +01:00
Patrick Lehmann
c8003f1a0e Added PyCharm project files. 2021-12-26 11:11:30 +01:00
Unai Martinez-Corral
6413469cdf v0.3.0 2021-12-26 01:40:09 +01:00
Unai Martinez-Corral
8dbacda32c Pytest using pyproject.toml (#29)
# New Features
* Allow configuration of the unit test directory (default: `tests/unit`).
* Allow configuration of a `pyproject.toml` or `.coveragerc` file.
* Extract values from `pyproject.toml` or `.coveragerc`.

# Changes
* Jobs deriving from template job `CoverageCollection` need to specify their `.coveragerc` content and `pytest.ini` content in a `pyproject.toml` file or provide the job parameter `coverage_config` with the path to the `.coveragerc` file.

# Bug Fixes
*None*

-------------
* Closes #2.
2021-12-25 23:40:50 +01:00
Patrick Lehmann
78b225195f Updated README according to latest changes. 2021-12-24 21:05:04 +01:00
umarcor
1fbeef36d6 CoverageCollection: skip config file if empty 2021-12-24 16:37:45 +01:00
umarcor
9846c9e60c CoverageCollection: use 'pyproject.toml' by default 2021-12-24 16:31:47 +01:00
umarcor
b8564eb389 CoverageCollection: xmlFile defaults to './coverage.xml' 2021-12-24 16:24:55 +01:00
umarcor
62cd2d1d0f CoverageCollection: htmlDirectory defaults to 'htmlcov' 2021-12-24 16:22:14 +01:00
umarcor
9bd8004dfb CoverageCollection: pass output directory to coverage html 2021-12-24 15:59:23 +01:00
umarcor
925b44a8a8 CoverageCollection: fix variable name 2021-12-24 15:54:09 +01:00
Patrick Lehmann
9d8c1ecc05 Merge branch 'dev' into toml 2021-12-24 14:15:28 +01:00
umarcor
66c7b4b619 ExamplePipeline/ArtifactCleanup: needs PublishTestResults instead of UnitTesting 2021-12-24 14:11:37 +01:00
Patrick Lehmann
b399aa8f93 Parameters: mark Python 3.6 black, update others, warn about unsupported versions 2021-12-24 14:00:34 +01:00
umarcor
dcd0a4b617 Parameters: mark Python 3.6 black, update others, warn about unsupported versions 2021-12-24 13:52:30 +01:00
Patrick Lehmann
d7c765ba79 Fixed how to access complex nested key-value pairs. 2021-12-24 13:04:31 +01:00
Patrick Lehmann
fa10ed076c Install dependency tomli before script execution. 2021-12-24 12:56:03 +01:00
Patrick Lehmann
9dfafd588e Changed scripting from bash to Python. Also use .coveragerc as fallback. 2021-12-24 12:55:59 +01:00
Patrick Lehmann
09f7504de4 Fixed path to project root. 2021-12-24 12:55:56 +01:00
Patrick Lehmann
6ad23eabf5 Extract information from TOML file. 2021-12-24 12:55:50 +01:00
Patrick Lehmann
bb855d572d Pytest using pyproject.toml. 2021-12-24 12:54:14 +01:00
umarcor
250cceb80d releaser: update README.md and DEVELOPMENT.md 2021-12-21 02:05:21 +01:00
umarcor
615aafc0b4 releaser: add DEVELOPMENT.md 2021-12-21 02:05:21 +01:00
umarcor
1f3d12ef95 README: add 'Container Step' to Context; add References 2021-12-21 01:39:02 +01:00
Unai Martinez-Corral
608670c6b9 v0.2.3
# Bug Fixes
*  releaser/composite: quote path to releaser.py (#27)
2021-12-21 01:02:13 +01:00
Unai Martinez-Corral
9cee3342e3 releaser/composite: quote path to releaser.py (#27) 2021-12-21 00:45:30 +01:00
jeremyd2019
aec2613cd1 releaser/composite: quote path to releaser.py
Fixes #26
2021-12-20 14:45:07 -08:00
Patrick Lehmann
7c406d96e7 v0.2.2 2021-12-20 08:53:56 +01:00
umarcor
459faf880a releaser: use GitHub CLI by default; remove option 'use-gh-cli' 2021-12-20 07:28:13 +01:00
umarcor
e832625624 releaser: refactor 2021-12-20 07:28:13 +01:00
umarcor
ee02a39a5e releaser: build and use image ghcr.io/pytooling/releaser 2021-12-20 07:28:13 +01:00
umarcor
52491e6bcc releaser: add option 'use-gh-cli' 2021-12-20 06:41:40 +01:00
umarcor
4177a535f1 releaser: refactor; add func GetOrCreateRelease 2021-12-20 06:41:40 +01:00
umarcor
548437b824 releaser: refactor; reorder CheckRefSemVer and GetRepositoryHandle 2021-12-20 06:41:39 +01:00
umarcor
596d0d774f releaser: refactor; add func GetRepositoryHandler 2021-12-20 06:41:39 +01:00
umarcor
877928ba4a releaser: refactor; add func CheckRefSemVer 2021-12-20 06:41:39 +01:00
umarcor
a06d90f456 releaser: refactor; add func UploadArtifacts 2021-12-20 06:41:33 +01:00
umarcor
dcaff1e5a1 releaser: refactor; add func GetReleaseHandler 2021-12-20 06:41:24 +01:00
umarcor
4d666520a0 releaser: refactor; add func GetGitHubAPIHandler 2021-12-20 06:41:19 +01:00
umarcor
cea369d703 releaser: refactor; add func GetListOfArtifacts 2021-12-20 06:41:13 +01:00
umarcor
08a19429d4 releaser: refactor; add func UpdateReference 2021-12-20 06:41:08 +01:00
umarcor
0cf056b6fe Revert "Added 'allow_failure' option for StaticTypeCheck job."
This reverts commit 6d94f6f471.
2021-12-16 07:39:51 +01:00
Patrick Lehmann
72b869a6fc Package: support either 'build' or 'setuptools' 2021-12-16 07:16:09 +01:00
umarcor
9255fdf781 Package: update description of option 'requirements 2021-12-16 06:59:16 +01:00
umarcor
5b2cd8f077 Package: support either 'build' or 'setuptools' 2021-12-16 06:50:03 +01:00
umarcor
85644b3456 ExamplePipeline: add option 'allow_failure' to StaticTypeCheck 2021-12-11 20:03:07 +01:00
Patrick Lehmann
6ff98fbb50 Added 'allow_failure' option for StaticTypeCheck job. 2021-12-11 20:01:33 +01:00
Patrick Lehmann
6d94f6f471 Added 'allow_failure' option for StaticTypeCheck job. 2021-12-11 16:59:02 +01:00
Unai Martinez-Corral
f736ec2e07 Add licenses (#11 ) 2021-12-07 19:46:30 +00:00
Patrick Lehmann
e33a3ce242 Removed unused exception variable. 2021-12-07 20:41:22 +01:00
Patrick Lehmann
59beccb198 Adjusted header blocks and added header blocks to files without license header. 2021-12-07 20:40:56 +01:00
Patrick Lehmann
bb26a274f3 Changed copyright holder. Reformatted list of authors. 2021-12-07 20:28:49 +01:00
Patrick Lehmann
6562cb4cd6 Added License and contributors to README. 2021-12-07 20:28:49 +01:00
Patrick Lehmann
d4ac697a4f Added license headers. 2021-12-07 20:28:49 +01:00
Patrick Lehmann
e77a0ecf98 Added licenses. 2021-12-07 20:27:04 +01:00
Unai Martinez-Corral
ce34dc098a Add a job template to publish unit test results (#13) 2021-12-07 19:14:38 +00:00
Patrick Lehmann
774ea7970e Added input parameter to the template and documented in the README. 2021-12-07 20:09:11 +01:00
Patrick Lehmann
ecd2f22ee6 Add Action 'releaser'. 2021-12-07 08:38:53 +01:00
Patrick Lehmann
4a8c4b6320 Rename reusable workflow 'Params' to 'Parameters'. 2021-12-07 08:36:51 +01:00
umarcor
0699b9f9e7 rename reusable workflow 'Params' to 'Parameters' 2021-12-07 04:51:24 +01:00
umarcor
e0c0b37621 ci/TestReleaser: do not run on 'v*' tags or 'r*' branches 2021-12-07 04:45:33 +01:00
umarcor
da1aedeb6b ci/TestReleaser: do not run on PRs 2021-12-07 04:35:42 +01:00
umarcor
5de7bff8b7 Releaser/README: add subsection 'Troubleshooting' 2021-12-07 04:34:07 +01:00
umarcor
add5afbf9d rename 'tip' to 'releaser' 2021-12-07 04:30:11 +01:00
umarcor
f1e0354afa merge v0.0.1 2021-12-07 04:22:20 +01:00
umarcor
00105dd491 UnitTesting: fix artifact upload condition 2021-12-07 03:27:09 +01:00
Patrick Lehmann
40856aa731 Removed to Issue Comment from job name. 2021-12-06 16:57:03 +01:00
Patrick Lehmann
c2f7d27321 Removed 'EnricoMi/publish-unit-test-result-action'. 2021-12-05 13:36:50 +01:00
Unai Martinez-Corral
c4e1cce63b add a Pull Request template (#14) 2021-12-04 22:21:03 +00:00
umarcor
d863682358 Tip/Dockerfile: use CMD instead of ENTRYPOINT 2021-12-04 20:33:18 +01:00
Patrick Lehmann
b0288cbe4b Added a PullRequest template. 2021-12-04 18:55:02 +01:00
Patrick Lehmann
4fac597238 Added job into example pipeline. 2021-12-04 18:46:15 +01:00
Patrick Lehmann
2b3b021c91 Added job template to publish unit test results. 2021-12-04 18:45:58 +01:00
umarcor
22afac70b8 Tip: style 2021-12-02 15:32:41 +01:00
umarcor
d297c02407 Tip: use 'files.append()' instead of 'files +=' 2021-12-02 15:27:10 +01:00
umarcor
0283c5f6a3 Tip: address codacy warnings 2021-12-02 05:11:46 +01:00
umarcor
6704be35b0 Tip/README: add subsection 'Composite Action' 2021-12-02 04:54:44 +01:00
umarcor
fbddab5a80 Tip/README: add 'Context' and 'Advanced/complex use cases' 2021-12-02 04:54:44 +01:00
umarcor
c4e236e627 Tip/README: update 'uses' field in the usage example 2021-12-02 04:38:04 +01:00
umarcor
aa63c214f8 ci/Tip: preprend subdir 'tip' to 'uses' fields 2021-12-02 04:38:00 +01:00
umarcor
6c119278c0 add Action 'tip' 2021-12-02 02:58:30 +01:00
umarcor
4df89a2f6a tip: prepare for merging into pyTooling/Actions 2021-12-02 02:54:41 +01:00
umarcor
9c31f34c4e ExamplePipeline: change name to just 'Pipeline' 2021-12-02 02:49:29 +01:00
umarcor
df86bea2f9 UnitTesting: update description of input 'jobs' 2021-12-02 02:48:48 +01:00
umarcor
2032cff787 ExamplePipeline/ArtifactCleanUp: needs UnitTesting 2021-12-01 08:30:00 +01:00
Patrick Lehmann
9c0c5084d1 add DEVELOPMENT.md
add DEVELOPMENT.md
2021-12-01 00:20:15 +01:00
umarcor
7803d6efb9 add DEVELOPMENT.md 2021-12-01 00:13:09 +01:00
umarcor
11ce447dda ExamplePipeline: run Package unconditionally; Release needs Package 2021-11-30 23:58:41 +01:00
Christoph Reiter
7bc8117e1d docker: revert to Python 3.9 (#163)
Related to #160. The errors started around the time when Python 3.10 was
released, so go back to 3.9.x to see if that is related.
2021-11-20 11:49:40 +01:00
eine
cec300fd51 composite: map inputs to envvars explicitly (actions/runner#665) 2021-11-15 22:59:35 +01:00
eine
0ae50caafe add 'composite' version of the Action 2021-11-15 22:59:35 +01:00
eine
5dbb1c55c1 use image 'python:slim-bullseye' instead of 'python:alpine' 2021-11-15 21:16:24 +01:00
eine
fb0c52cbfb improve listing of glob results 2021-10-18 02:17:49 +02:00
eine
02db3d0242 improve handling of upload failures 2021-10-18 01:49:38 +02:00
eine
c5d663973f run black 2021-10-18 01:33:27 +02:00
eine
090df199ac add pyproject.toml 2021-10-18 01:32:56 +02:00
eine
257749f997 use fstrings 2021-10-18 01:32:17 +02:00
eine
0698ef44ac ci: add workflow_dispatch and cron event 2021-07-17 20:25:12 +02:00
eine
0b4083dfda support not uploading assets, through 'files: none' 2021-01-12 20:41:15 +01:00
eine
86bdfdbb1b treat non semver compliat tags as releases 2021-01-06 07:22:18 +01:00
eine
4c1a1385fb fix: do not crash if tag is not semver compliant 2020-10-10 19:54:08 +02:00
eine
ceecb32683 accept semver tags starting with 'v' 2020-10-10 19:52:22 +02:00
eine
2d1af55952 print warning about skipping snapshots 2020-10-10 18:53:04 +02:00
eine
4763c86e77 fix: use non-snapshot prerelease tags 2020-10-10 18:51:35 +02:00
eine
13eab642be ci: fix branch name filter 2020-10-10 18:27:19 +02:00
eine
9b5ac360b7 skip empty files (#159) 2020-10-10 18:27:07 +02:00
eine
642b99b75d set glob recursive=True 2020-10-10 18:21:28 +02:00
eine
4faf2667a2 fix naming of tmp assets 2020-07-26 19:19:48 +02:00
eine
fe58d3aba3 add option 'snapshots' 2020-07-26 06:54:02 +02:00
eine
fc695b9661 upload, remove, rename (#157) 2020-07-26 02:08:34 +02:00
eine
b4dbe55c26 update README.md 2020-07-26 00:54:39 +02:00
Lucy Linder
6cf8de253a add option 'rm' (#156) 2020-06-06 20:22:05 +02:00
eine
65fae902fc fix paths with subdirs 2020-05-15 05:37:39 +02:00
eine
c9d3643b20 initial commit 2020-05-14 18:38:01 +02:00
35 changed files with 1940 additions and 178 deletions

18
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
version: 2
updates:
# Maintain GitHub Action runners
- package-ecosystem: "github-actions"
directory: "/"
target-branch: dev
commit-message:
prefix: "[Dependabot]"
labels:
- Dependencies
assignees:
- Paebbels
- Umarcor
reviewers:
- Paebbels
- Umarcor
schedule:
interval: "daily" # Checks on Monday trough Friday.

16
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,16 @@
# New Features
* tbd
# Changes
* tbd
# Bug Fixes
* tbd
----------
# Related PRs:
* tbd

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: ArtifactCleanUp
on:
@@ -23,12 +45,12 @@ jobs:
- name: 🗑️ Delete package Artifacts
if: ${{ ! startsWith(github.ref, 'refs/tags') }}
uses: geekyeggo/delete-artifact@v1
uses: geekyeggo/delete-artifact@v2
with:
name: ${{ inputs.package }}
- name: 🗑️ Delete remaining Artifacts
if: ${{ inputs.remaining != '' }}
uses: geekyeggo/delete-artifact@v1
uses: geekyeggo/delete-artifact@v2
with:
name: ${{ inputs.remaining }}

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Documentation
on:
@@ -16,7 +38,7 @@ jobs:
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: 🛳️ Build documentation
uses: buildthedocs/btd@v0
@@ -24,7 +46,7 @@ jobs:
skip-deploy: true
- name: 📤 Upload 'documentation' artifacts
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact }}
path: doc/_build/html

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Coverage Collection
on:
@@ -13,6 +35,16 @@ on:
required: false
default: '-r tests/requirements.txt'
type: string
unittest_directory:
description: 'Path to the directory containing unit tests.'
required: false
default: 'tests/unit'
type: string
coverage_config:
description: 'Path to the .coveragerc file. Use pyproject.toml by default.'
required: false
default: 'pyproject.toml'
type: string
artifact:
description: 'Name of the coverage artifact.'
required: true
@@ -30,45 +62,90 @@ jobs:
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: 🐍 Setup Python ${{ inputs.python_version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
- name: 🗂 Install dependencies
run: |
python -m pip install -U pip
python -m pip install tomli
python -m pip install ${{ inputs.requirements }}
- name: 🔁 Extract configurations from pyproject.toml
id: getVariables
shell: python
run: |
from os import environ
from pathlib import Path
from tomli import load as tomli_load
htmlDirectory = 'htmlcov'
xmlFile = './coverage.xml'
coverageRC = "${{ inputs.coverage_config }}".strip()
# Read output paths from 'pyproject.toml' file
if coverageRC == "pyproject.toml":
pyProjectFile = Path("pyproject.toml")
if pyProjectFile.exists():
with pyProjectFile.open("rb") as file:
pyProjectSettings = tomli_load(file)
htmlDirectory = pyProjectSettings["tool"]["coverage"]["html"]["directory"]
xmlFile = pyProjectSettings["tool"]["coverage"]["xml"]["output"]
else:
print(f"File '{pyProjectFile}' not found and no ' .coveragerc' file specified.")
# Read output paths from '.coveragerc' file
elif len(coverageRC) > 0:
coverageRCFile = Path(coverageRC)
if coverageRCFile.exists():
with coverageRCFile.open("rb") as file:
coverageRCSettings = tomli_load(file)
htmlDirectory = coverageRCSettings["html"]["directory"]
xmlFile = coverageRCSettings["xml"]["output"]
else:
print(f"File '{coverageRCFile}' not found.")
with open(environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as gho:
gho.write(f"""\
coverage_report_html_directory={htmlDirectory}
coverage_report_xml={xmlFile}
""")
print(f"DEBUG:\n html={htmlDirectory}\n xml={xmlFile}")
- name: Collect coverage
continue-on-error: true
run: |
python -m pytest -rA --cov=.. --cov-config=tests/.coveragerc tests/unit --color=yes
[ 'x${{ inputs.coverage_config }}' != 'x' ] && PYCOV_ARGS='--cov-config=${{ inputs.coverage_config }}' || unset PYCOV_ARGS
python -m pytest -rA --cov=. $PYCOV_ARGS ${{ inputs.unittest_directory }} --color=yes
- name: Convert to cobertura format
run: coverage xml
- name: Convert to HTML format
run: |
coverage html
rm htmlcov/.gitignore
coverage html -d ${{ steps.getVariables.outputs.coverage_report_html_directory }}
rm ${{ steps.getVariables.outputs.coverage_report_html_directory }}/.gitignore
- name: 📤 Upload 'Coverage Report' artifact
continue-on-error: true
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact }}
path: htmlcov
path: ${{ steps.getVariables.outputs.coverage_report_html_directory }}
if-no-files-found: error
retention-days: 1
- name: 📊 Publish coverage at CodeCov
continue-on-error: true
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
files: ${{ steps.getVariables.outputs.coverage_report_xml }}
flags: unittests
env_vars: PYTHON
@@ -77,4 +154,4 @@ jobs:
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.codacy_token }}
coverage-reports: ./coverage.xml
coverage-reports: ${{ steps.getVariables.outputs.coverage_report_xml }}

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Package
on:
@@ -9,9 +31,9 @@ on:
default: '3.10'
type: string
requirements:
description: 'Python dependencies to be installed through pip.'
description: 'Python dependencies to be installed through pip; if empty, use pyproject.toml through build.'
required: false
default: 'wheel'
default: ''
type: string
artifact:
description: 'Name of the package artifact.'
@@ -26,26 +48,61 @@ jobs:
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: 🐍 Setup Python ${{ inputs.python_version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
- name: 🔧 Install dependencies for packaging and release
run: |
python -m pip install -U pip
python -m pip install ${{ inputs.requirements }}
- name: 🐍 Update pip
run: python -m pip install -U pip
- name: 🔨 Build Python package (source distribution)
# build
- name: 🔧 [build] Install dependencies for packaging and release
if: inputs.requirements == ''
run: python -m pip install build
- name: 🔨 [build] Build Python package (source distribution)
if: inputs.requirements == ''
run: python -m build --sdist
- name: 🔨 [build] Build Python package (binary distribution - wheel)
if: inputs.requirements == ''
run: python -m build --wheel
# build (not isolated)
- name: 🔧 [build] Install dependencies for packaging and release
if: inputs.requirements == 'no-isolation'
run: python -m pip install build
- name: 🔨 [build] Build Python package (source distribution)
if: inputs.requirements == 'no-isolation'
run: python -m build --no-isolation --sdist
- name: 🔨 [build] Build Python package (binary distribution - wheel)
if: inputs.requirements == 'no-isolation'
run: python -m build --no-isolation --wheel
# setuptools
- name: 🔧 [setuptools] Install dependencies for packaging and release
if: inputs.requirements != '' && inputs.requirements != 'no-isolation'
run: python -m pip install ${{ inputs.requirements }}
- name: 🔨 [setuptools] Build Python package (source distribution)
if: inputs.requirements != '' && inputs.requirements != 'no-isolation'
run: python setup.py sdist
- name: 🔨 Build Python package (binary distribution - wheel)
- name: 🔨 [setuptools] Build Python package (binary distribution - wheel)
if: inputs.requirements != '' && inputs.requirements != 'no-isolation'
run: python setup.py bdist_wheel
- name: 📤 Upload wheel artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact }}
path: dist/

124
.github/workflows/Parameters.yml vendored Normal file
View File

@@ -0,0 +1,124 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Parameters
on:
workflow_call:
inputs:
python_version:
description: 'Python version.'
required: false
default: '3.10'
type: string
python_version_list:
description: 'Space separated list of Python versions to run tests with.'
required: false
default: '3.7 3.8 3.9 3.10'
type: string
system_list:
description: 'Space separated list of systems to run tests on.'
required: false
default: 'ubuntu windows msys2 macos'
type: string
name:
description: 'Name of the tool.'
required: true
type: string
outputs:
params:
description: "Parameters to be used in other jobs."
value: ${{ jobs.Parameters.outputs.params }}
python_jobs:
description: "List of Python versions to be used in the matrix of other jobs."
value: ${{ jobs.Parameters.outputs.python_jobs }}
jobs:
Parameters:
runs-on: ubuntu-latest
outputs:
params: ${{ steps.params.outputs.params }}
python_jobs: ${{ steps.params.outputs.python_jobs }}
steps:
- name: Generate 'params' and 'python_jobs'
id: params
shell: python
run: |
from os import environ
name = '${{ inputs.name }}'
params = {
'python_version': '${{ inputs.python_version }}',
'artifacts': {
'unittesting': f'{name}-TestReport',
'coverage': f'{name}-coverage',
'typing': f'{name}-typing',
'package': f'{name}-package',
'doc': f'{name}-doc',
}
}
with open(environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as gho:
gho.write(f"params={params!s}\n")
print("Parameters:")
print(params)
systems = '${{ inputs.system_list }}'.split(' ')
versions = '${{ inputs.python_version_list }}'.split(' ')
if '3.6' in versions:
print("::warning title=Deprecated::Support for Python 3.6 ended in 2021.12.23.")
if '3.11' in versions:
print(f"::notice title=Experimental::Python 3.11 (3.11.0-alpha3) is a pre-release.")
data = {
'python': {
'3.6': { 'icon': '⚫', 'until': '2021.12.23' },
'3.7': { 'icon': '🔴', 'until': '2023.06.27' },
'3.8': { 'icon': '🟠', 'until': '2024.10' },
'3.9': { 'icon': '🟡', 'until': '2025.10' },
'3.10': { 'icon': '🟢', 'until': '2026.10' },
'3.11': { 'icon': '🟣', 'until': '2027.10' },
},
'sys': {
'ubuntu': { 'icon': '🐧', 'runs-on': 'ubuntu-latest', 'shell': 'bash' },
'windows': { 'icon': '🧊', 'runs-on': 'windows-latest', 'shell': 'pwsh' },
'msys2': { 'icon': '🟦', 'runs-on': 'windows-latest', 'shell': 'msys2 {0}' },
'macos': { 'icon': '🍎', 'runs-on': 'macos-latest', 'shell': 'bash' }
}
}
jobs = [
{
'sysicon': data['sys'][system]['icon'],
'system': system,
'runs-on': data['sys'][system]['runs-on'],
'shell': data['sys'][system]['shell'],
'pyicon': data['python'][version]['icon'],
'python': '3.11.0-alpha.3' if version == '3.11' else version
}
for system in systems
for version in (versions if system != 'msys2' else ['3.10'])
]
with open(environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as gho:
gho.write(f"python_jobs={jobs!s}\n")
print("Python jobs:")
print(jobs)

View File

@@ -1,69 +0,0 @@
name: Params
on:
workflow_call:
inputs:
python_version:
description: 'Python version.'
required: false
default: '3.10'
type: string
python_version_list:
description: 'Space separated list of Python versions to run tests with.'
required: false
default: '3.6 3.7 3.8 3.9 3.10'
type: string
name:
description: 'Name of the tool.'
required: true
type: string
outputs:
params:
description: "Parameters to be used in other jobs."
value: ${{ jobs.Params.outputs.params }}
python_jobs:
description: "List of Python versions to be used in the matrix of other jobs."
value: ${{ jobs.Params.outputs.python_jobs }}
jobs:
Params:
runs-on: ubuntu-latest
outputs:
params: ${{ steps.params.outputs.params }}
python_jobs: ${{ steps.params.outputs.python_jobs }}
steps:
- name: Generate 'params' and 'python_jobs'
id: params
shell: python
run: |
name = '${{ inputs.name }}'
params = {
'python_version': '${{ inputs.python_version }}',
'artifacts': {
'unittesting': f'{name}-TestReport',
'coverage': f'{name}-coverage',
'typing': f'{name}-typing',
'package': f'{name}-package',
'doc': f'{name}-doc',
}
}
print(f'::set-output name=params::{params!s}')
print("Params:")
print(params)
data = {
'3.6': { 'icon': '🔴', 'until': '23.12.2021' },
'3.7': { 'icon': '🟠', 'until': '27.06.2023' },
'3.8': { 'icon': '🟡', 'until': 'Oct. 2024' },
'3.9': { 'icon': '🟢', 'until': 'Oct. 2025' },
'3.10': { 'icon': '🟢', 'until': 'Oct. 2026' },
}
jobs = [
{'python': version, 'icon': data[version]['icon']}
for version in '${{ inputs.python_version_list }}'.split(' ')
]
print(f'::set-output name=python_jobs::{jobs!s}')
print("Python jobs:")
print(jobs)

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Publish on PyPI
on:
@@ -30,13 +52,13 @@ jobs:
steps:
- name: 📥 Download artifacts '${{ inputs.artifact }}' from 'Package' job
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact }}
path: dist/
- name: 🐍 Setup Python ${{ inputs.python_version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}

View File

@@ -0,0 +1,54 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Publish Unit Test Results
on:
workflow_call:
inputs:
report_files:
description: 'Pattern of report files to upload. Can be a comma separated list.'
required: false
default: 'artifacts/**/*.xml'
type: string
jobs:
PublishTestResults:
name: 📊 Publish Test Results
runs-on: ubuntu-latest
if: always()
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: 📊 Publish Unit Test Results
uses: dorny/test-reporter@v1
with:
name: Unit Test Results
path: ${{ inputs.report_files }}
reporter: java-junit

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Publish to GitHub Pages
on:
@@ -26,24 +48,24 @@ jobs:
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: 📥 Download artifacts '${{ inputs.doc }}' from 'BuildTheDocs' job
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: ${{ inputs.doc }}
path: public
- name: 📥 Download artifacts '${{ inputs.coverage }}' from 'Coverage' job
if: ${{ inputs.coverage != '' }}
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: ${{ inputs.coverage }}
path: public/coverage
- name: 📥 Download artifacts '${{ inputs.typing }}' from 'StaticTypeCheck' job
if: ${{ inputs.typing != '' }}
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: ${{ inputs.typing }}
path: public/typing

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Release
on:
@@ -17,9 +39,11 @@ jobs:
RELEASE_VERSION=${GIT_TAG#v}
RELEASE_DATETIME="$(date --utc '+%d.%m.%Y - %H:%M:%S')"
# write to step outputs
echo ::set-output name=gitTag::${GIT_TAG}
echo ::set-output name=version::${RELEASE_VERSION}
echo ::set-output name=datetime::${RELEASE_DATETIME}
cat >> "$GITHUB_OUTPUT" << EOF
gitTag=${GIT_TAG}
version=${RELEASE_VERSION}
datetime=${RELEASE_DATETIME}
EOF
- name: 📑 Create Release Page
id: createReleasePage

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Static Type Check
on:
@@ -35,10 +57,10 @@ jobs:
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: 🐍 Setup Python ${{ inputs.python_version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
@@ -54,7 +76,7 @@ jobs:
- name: 📤 Upload 'Static Typing Report' artifact
if: ${{ inputs.artifact != '' }}
continue-on-error: true
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact }}
path: ${{ inputs.report }}

176
.github/workflows/TestReleaser.yml vendored Normal file
View File

@@ -0,0 +1,176 @@
# ==================================================================================================================== #
# Authors: #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Test Releaser
on:
push:
tags:
- '*'
- '!tip'
- '!v*'
branches:
- '**'
- '!r*'
workflow_dispatch:
schedule:
- cron: '0 0 * * 4'
env:
CI: true
jobs:
Image:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v3
- name: Build container image
run: docker build -t ghcr.io/pytooling/releaser -f releaser/Dockerfile releaser
- name: Push container image
uses: ./with-post-step
with:
main: |
echo '${{ github.token }}' | docker login ghcr.io -u GitHub-Actions --password-stdin
docker push ghcr.io/pytooling/releaser
post: docker logout ghcr.io
Composite:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo "Build some tool and generate some (versioned) artifacts" > artifact-$(date -u +"%Y-%m-%dT%H-%M-%SZ").txt
- name: Single
uses: ./releaser/composite
with:
rm: true
token: ${{ secrets.GITHUB_TOKEN }}
files: artifact-*.txt
- name: List
uses: ./releaser/composite
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
artifact-*.txt
README.md
- name: Add artifacts/*.txt
run: |
mkdir artifacts
echo "Build some tool and generate some artifacts" > artifacts/artifact.txt
touch artifacts/empty_file.txt
- name: Single in subdir
uses: ./releaser/composite
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/artifact.txt
- name: Add artifacts/*.md
run: |
echo "releaser hello" > artifacts/hello.md
echo "releaser world" > artifacts/world.md
- name: Directory wildcard
uses: ./releaser/composite
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/*
- name: Add artifacts/subdir
run: |
mkdir artifacts/subdir
echo "Test recursive glob" > artifacts/subdir/deep_file.txt
- name: Directory wildcard (recursive)
uses: ./releaser/composite
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/**
Test:
needs:
- Image
- Composite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo "Build some tool and generate some (versioned) artifacts" > artifact-$(date -u +"%Y-%m-%dT%H-%M-%SZ").txt
- name: Single
uses: ./releaser
with:
rm: true
token: ${{ secrets.GITHUB_TOKEN }}
files: artifact-*.txt
- name: List
uses: ./releaser
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
artifact-*.txt
README.md
- name: Add artifacts/*.txt
run: |
mkdir artifacts
echo "Build some tool and generate some artifacts" > artifacts/artifact.txt
touch artifacts/empty_file.txt
- name: Single in subdir
uses: ./releaser
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/artifact.txt
- name: Add artifacts/*.md
run: |
echo "releaser hello" > artifacts/hello.md
echo "releaser world" > artifacts/world.md
- name: Directory wildcard
uses: ./releaser
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/*
- name: Add artifacts/subdir
run: |
mkdir artifacts/subdir
echo "Test recursive glob" > artifacts/subdir/deep_file.txt
- name: Directory wildcard (recursive)
uses: ./releaser
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/**

View File

@@ -1,10 +1,32 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Unit Testing
on:
workflow_call:
inputs:
jobs:
description: 'Space separated list of Python versions to run tests with.'
description: 'JSON list with environment fields, telling the system and Python versions to run tests with.'
required: true
type: string
requirements:
@@ -12,6 +34,25 @@ on:
required: false
default: '-r tests/requirements.txt'
type: string
pacboy:
description: 'MSYS2 dependencies to be installed through pacboy (pacman).'
required: false
default: >-
python-pip:p
python-wheel:p
python-coverage:p
python-lxml:p
type: string
mingw_requirements:
description: 'Override Python dependencies to be installed through pip on MSYS2 (MINGW64) only.'
required: false
default: ''
type: string
unittest_directory:
description: 'Path to the directory containing unit tests.'
required: false
default: 'tests/unit'
type: string
artifact:
description: "Generate unit test report with junitxml and upload results as an artifact."
required: false
@@ -21,38 +62,71 @@ on:
jobs:
UnitTesting:
name: ${{ matrix.icon }} Unit Tests using Python ${{ matrix.python }}
runs-on: ubuntu-latest
name: ${{ matrix.sysicon }} ${{ matrix.pyicon }} Unit Tests using Python ${{ matrix.python }}
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(inputs.jobs) }}
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: '🟦 Setup MSYS2'
if: matrix.system == 'msys2'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
pacboy: ${{ inputs.pacboy }}
- name: 🐍 Setup Python ${{ matrix.python }}
uses: actions/setup-python@v2
if: matrix.system != 'msys2'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: 🔧 Install dependencies
- name: ⚙️ Update pip
run: python -m pip install -U pip
- name: 🔧 Install wheel and pip dependencies
if: matrix.system != 'msys2'
run: |
python -m pip install -U pip
python -m pip install -U wheel
python -m pip install ${{ inputs.requirements }}
- name: 🔧 Install pip dependencies
if: matrix.system == 'msys2'
run: |
if [ 'x${{ inputs.mingw_requirements }}' != 'x' ]; then
python -m pip install ${{ inputs.mingw_requirements }}
else
python -m pip install ${{ inputs.requirements }}
fi
- name: ☑ Run unit tests
if: matrix.system == 'windows'
run: |
$PYTEST_ARGS = if ("${{ inputs.artifact }}".length -gt 0) { "--junitxml=TestReport.xml" } else { "" }
python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes
- name: ☑ Run unit tests
if: matrix.system != 'windows'
run: |
[ 'x${{ inputs.artifact }}' != 'x' ] && PYTEST_ARGS='--junitxml=TestReport.xml' || unset PYTEST_ARGS
python -m pytest -rA tests/unit $PYTEST_ARGS --color=yes
python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes
- name: 📤 Upload 'TestReport.xml' artifact
if: inputs.TestReport == 'true'
uses: actions/upload-artifact@v2
if: inputs.artifact != ''
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact }}-${{ matrix.python }}
name: ${{ inputs.artifact }}-${{ matrix.system }}-${{ matrix.python }}
path: TestReport.xml
if-no-files-found: error
retention-days: 1

View File

@@ -1,3 +1,25 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Verify examples
on:
@@ -17,10 +39,10 @@ jobs:
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: 🐍 Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}

8
.idea/Actions.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Actions.iml" filepath="$PROJECT_DIR$/.idea/Actions.iml" />
</modules>
</component>
</project>

22
DEVELOPMENT.md Normal file
View File

@@ -0,0 +1,22 @@
# Development
## Tagging/versioning
See context in [#5](https://github.com/pyTooling/Actions/issues/5).
Tag new releases in the `main` branch using a semver compatible value, starting with `v`:
```sh
git checkout main
git tag v0.0.0
git push upstream v0.0.0
```
Move the corresponding release branch (starting with `r`) forward by creating a merge commit, and using the merged tag
as the commit message:
```sh
git checkout r0
git merge --no-ff -m 'v0.0.0' v0.0.0
git push upstream r0
```

View File

@@ -1,4 +1,26 @@
name: Unit Testing, Coverage Collection, Package, Release, Documentation and Publish
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: Pipeline
on:
workflow_dispatch:
@@ -8,10 +30,11 @@ jobs:
# This job is a workaround for global variables
# See https://github.com/actions/runner/issues/480
Params:
uses: pyTooling/Actions/.github/workflows/Params.yml@main
uses: pyTooling/Actions/.github/workflows/Parameters.yml@main
with:
name: ToolName
# Optional
system_list: 'ubuntu windows msys2 macos'
python_version: '3.10'
python_version_list: '3.8 3.9 3.10'
@@ -23,6 +46,13 @@ jobs:
jobs: ${{ needs.Params.outputs.python_jobs }}
# Optional
requirements: '-r tests/requirements.txt'
pacboy: >-
python-pip:p
python-wheel:p
python-coverage:p
python-lxml:p
mingw_requirements: '-r tests/requirements.mingw.txt'
unittest_directory: 'tests/unit'
artifact: ${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}
Coverage:
@@ -48,18 +78,18 @@ jobs:
python_version: ${{ fromJson(needs.Params.outputs.params).python_version }}
requirements: '-r tests/requirements.txt'
report: 'htmlmypy'
allow_failure: true
Release:
uses: pyTooling/Actions/.github/workflows/Release.yml@main
if: startsWith(github.ref, 'refs/tags')
PublishTestResults:
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@main
needs:
- UnitTesting
- Coverage
- StaticTypeCheck
with:
# Optional
report_files: artifacts/**/*.xml
Package:
uses: pyTooling/Actions/.github/workflows/Package.yml@main
if: startsWith(github.ref, 'refs/tags')
needs:
- Params
- Coverage
@@ -69,6 +99,15 @@ jobs:
python_version: ${{ fromJson(needs.Params.outputs.params).python_version }}
requirements: 'wheel'
Release:
uses: pyTooling/Actions/.github/workflows/Release.yml@main
if: startsWith(github.ref, 'refs/tags')
needs:
- UnitTesting
- Coverage
- StaticTypeCheck
- Package
PublishOnPyPI:
uses: pyTooling/Actions/.github/workflows/PublishOnPyPI.yml@main
if: startsWith(github.ref, 'refs/tags')
@@ -117,6 +156,7 @@ jobs:
uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@main
needs:
- Params
- PublishTestResults
- Coverage
- StaticTypeCheck
- BuildTheDocs

View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

BIN
ExamplePipeline_light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

82
LICENSE.md Normal file
View File

@@ -0,0 +1,82 @@
This is a local copy of the Apache License Version 2.0.
The original can be obtained here: [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
--------------------------------------------------------------------------------
# Apache License
Version 2.0, January 2004
## TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
### 1. Definitions.
*"License"* shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
*"Licensor"* shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
*"Legal Entity"* shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
*"You"* (or *"Your"*) shall mean an individual or Legal Entity exercising permissions granted by this License.
*"Source"* form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
*"Object"* form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
*"Work"* shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
*"Derivative Works"* shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
*"Contribution"* shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, *"submitted"* means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as *"Not a Contribution."*
*"Contributor"* shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
### 2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
### 3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
### 4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
- You must give any other recipients of the Work or Derivative Works a copy of this License; and
- You must cause any modified files to carry prominent notices stating that You changed the files; and
- You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
- If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
### 5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
### 6. Trademarks.
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
### 7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
### 8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
### 9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
## Appendix: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -7,24 +7,30 @@ language for writing reusable CI code.
However, Python being equally popular and capable, usage of JS/TS might be bypassed, with some caveats.
This repository gathers reusable CI tooling for testing, packaging and distributing Python projects and documentation.
## Context
GitHub Actions supports four types of reusable code:
GitHub Actions supports five procedures to reuse code:
- JavaScript Action.
- JavaScript Action:
- [docs.github.com: actions/creating-actions/creating-a-javascript-action](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action)
- Container Action.
- Container Action:
- [docs.github.com: actions/creating-actions/creating-a-docker-container-action](https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action)
- Composite Action.
- Container Step:
- [docs.github.com: actions/learn-github-actions/workflow-syntax-for-github-actions#example-using-a-docker-public-registry-action](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-using-a-docker-public-registry-action)
- [docs.github.com: actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithargs](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithargs)
- Composite Action:
- [docs.github.com: actions/creating-actions/creating-a-composite-action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action)
- [github.blog/changelog: 2020-08-07-github-actions-composite-run-steps](https://github.blog/changelog/2020-08-07-github-actions-composite-run-steps/)
- [github.blog/changelog: 2021-08-25-github-actions-reduce-duplication-with-action-compositio](https://github.blog/changelog/2021-08-25-github-actions-reduce-duplication-with-action-composition/)
- Reusable Workflows.
- Reusable Workflow:
- [docs.github.com: actions/learn-github-actions/reusing-workflows](https://docs.github.com/en/actions/learn-github-actions/reusing-workflows)
- [github.blog/changelog: 2021-10-05-github-actions-dry-your-github-actions-configuration-by-reusing-workflows](https://github.blog/changelog/2021-10-05-github-actions-dry-your-github-actions-configuration-by-reusing-workflows/)
Leaving JavaScript and Container Actions aside, the main differences between Composite Actions and Reusable Workflows
are the following:
Container Actions and Container Steps are almost equivalent: Actions use a configuration file (`action.yml`), while
Steps do not.
Leaving JavaScript and Container Actions and Steps aside, the main differences between Composite Actions and Reusable
Workflows are the following:
- Composite Actions can be executed from a remote/external path or from the checked out branch, and from any location.
However, Reusable Workflows can only be used through a remote/external path (`{owner}/{repo}/{path}/{filename}@{ref}`),
@@ -53,7 +59,7 @@ In dispatchable Workflows, the object is `${{ github.event.inputs }}`, while cal
As a result, in order to make a reusable workflow dispatchable, a wrapper workflow is required.
See, for instance, [hdl/containers: .github/workflows/common.yml](https://github.com/hdl/containers/blob/main/.github/workflows/common.yml) and [hdl/containers: .github/workflows/dispatch.yml](https://github.com/hdl/containers/blob/main/.github/workflows/dispatch.yml).
Alternatively, a normalisation job might be used, similar to the `Params` in this repo.
Alternatively, a normalisation job might be used, similar to the `Parameters` in this repo.
### Call hierarchy
@@ -74,6 +80,7 @@ It allows using the `post` feature with scripts written in bash, python or any o
the environment.
See: [actions/runner#1478](https://github.com/actions/runner/issues/1478).
## Reusable workflows
This repository provides 10+ Reusable Workflows based on the CI pipelines of the repos in this organisation,
@@ -81,20 +88,25 @@ This repository provides 10+ Reusable Workflows based on the CI pipelines of the
By combining them, Python packages can be continuously tested and released along with Sphinx documentation sites, to GitHub Releases, GitHub Pages and PyPI.
Optionally, coverage and static type check reports can be gathered.
[![](ExamplePipeline.png)](ExamplePipeline.png)
[![](ExamplePipeline_dark.png)](ExamplePipeline_dark.png)
As shown in the screenshot above, the expected order is:
[![](ExamplePipeline_light.png)](ExamplePipeline_light.png)
As shown in the screenshots above, the expected order is:
- Global:
- [Params](.github/workflows/Params.yml): a workaround for the limitations to handle global variables in
- [Parameters](.github/workflows/Parameters.yml): a workaround for the limitations to handle global variables in
GitHub Actions workflows (see [actions/runner#480](https://github.com/actions/runner/issues/480)).
It generates outputs with artifact names and job matrices to be used in other jobs.
It generates outputs with artifact names and job matrices to be used in later running jobs.
- Code testing/analysis:
- [UnitTesting](.github/workflows/UnitTesting.yml): run unit test with `pytest` using multiple versions of Python, and
optionally upload results as XML reports.
- [CoverageCollection](.github/workflows/CoverageCollection.yml): collect coverage data with `pytest` using a single
version of Python, generate HTML and Cobertura (XML) reports, upload the HTML report as an artifact, and upload the
results to Codecov and Codacy.
optionally upload results as XML reports. Configuration options to `pytest` should be given via section
`[tool.pytest.ini_options]` in a `pyproject.toml` file.
- [CoverageCollection](.github/workflows/CoverageCollection.yml): collect code coverage data (incl. branch coverage)
with `pytest`/`pytest-cov`/`coverage.py` using a single version of Python (latest). It generates HTML and Cobertura
(XML)reports, upload the HTML report as an artifact, and upload the test results to Codecov and Codacy. Configuration
options to `pytest` and `coverage.py` should be given via section `[tool.pytest.ini_options]` and `[tool.coverage.*]`
in a `pyproject.toml` file.
- [StaticTypeCheck](.github/workflows/StaticTypeCheck.yml): collect static type check result with `mypy`, and
optionally upload results as an HTML report.
Example `commands`:
@@ -121,11 +133,12 @@ As shown in the screenshot above, the expected order is:
mypy --html-report ../htmlmypy -p ToolName
```
- [VerifyDocs](.github/workflows/VerifyDocs.yml): extract code examples from the README and test.
- [VerifyDocs](.github/workflows/VerifyDocs.yml): extract code examples from the README and test these code snippets.
- Packaging and releasing:
- [Release](.github/workflows/Release.yml): publish GitHub Release.
- [Package](.github/workflows/Package.yml): generate source and wheel packages, and upload them as an artifact.
- [PublishOnPyPI](.github/workflows/PublishOnPyPI.yml): publish source and wheel packages to PyPI.
- [PublishTestResults](.github/workflows/PublishTestResults.yml): publish unit test results through GH action `dorny/test-reporter`.
- Documentation:
- [BuildTheDocs](.github/workflows/BuildTheDocs.yml): build Sphinx documentation with BuildTheDocs, and upload HTML as
an artifact.
@@ -139,7 +152,7 @@ As shown in the screenshot above, the expected order is:
Python package/tool developers can copy it into their repos, in order to use al the reusable workflows straightaway.
Minimal required modifications are the following:
- Set the `name` input of job `Params`.
- Set the `name` input of job `Parameters`.
- Specify the `commands` input of job `StaticTypeCheck`.
Find further usage cases in the following list of projects:
@@ -147,3 +160,25 @@ Find further usage cases in the following list of projects:
- [edaa-org/pyEDAA.ProjectModel](https://github.com/edaa-org/pyEDAA.ProjectModel/tree/main/.github/workflows)
- [edaa-org/pySVModel](https://github.com/edaa-org/pySVModel/tree/main/.github/workflows)
- [VHDL/pyVHDLModel](https://github.com/VHDL/pyVHDLModel/tree/main/.github/workflows)
## References
- [hdl/containers#48](https://github.com/hdl/containers/issues/48)
## Contributors
* [Patrick Lehmann](https://GitHub.com/Paebbels)
* [Unai Martinez-Corral](https://GitHub.com/umarcor) (Maintainer)
* [and more...](https://GitHub.com/pyTooling/Actions/graphs/contributors)
## License
This Python package (source code) licensed under [Apache License 2.0](LICENSE.md).
The accompanying documentation is licensed under [Creative Commons - Attribution 4.0 (CC-BY 4.0)](doc/Doc-License.rst).
---
SPDX-License-Identifier: Apache-2.0

353
doc/Doc-License.rst Normal file
View File

@@ -0,0 +1,353 @@
.. _DOCLICENSE:
.. Note:: This is a local copy of the `Creative Commons - Attribution 4.0 International (CC BY 4.0) <https://creativecommons.org/licenses/by/4.0/legalcode>`__.
.. Attention:: This **CC BY 4.0** license applies only to the **documentation** of this project.
Creative Commons Attribution 4.0 International
##############################################
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not
provide legal services or legal advice. Distribution of Creative Commons public
licenses does not create a lawyer-client or other relationship. Creative Commons
makes its licenses and related information available on an “as-is” basis.
Creative Commons gives no warranties regarding its licenses, any material
licensed under their terms and conditions, or any related information. Creative
Commons disclaims all liability for damages resulting from their use to the
fullest extent possible.
.. topic:: Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and conditions
that creators and other rights holders may use to share original works of
authorship and other material subject to copyright and certain other rights
specified in the public license below. The following considerations are for
informational purposes only, are not exhaustive, and do not form part of our
licenses.
* **Considerations for licensors:** Our public licenses are intended for use
by those authorized to give the public permission to use material in ways
otherwise restricted by copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms and conditions
of the license they choose before applying it. Licensors should also secure
all rights necessary before applying our licenses so that the public can reuse
the material as expected. Licensors should clearly mark any material not
subject to the license. This includes other CC-licensed material, or material
used under an exception or limitation to copyright.
`More considerations for licensors <http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors>`__.
* **Considerations for the public:** By using one of our public licenses, a
licensor grants the public permission to use the licensed material under
specified terms and conditions. If the licensors permission is not necessary
for any reasonfor example, because of any applicable exception or limitation
to copyrightthen that use is not regulated by the license. Our licenses grant
only permissions under copyright and certain other rights that a licensor has
authority to grant. Use of the licensed material may still be restricted for
other reasons, including because others have copyright or other rights in the
material. A licensor may make special requests, such as asking that all
changes be marked or described. Although not required by our licenses, you are
encouraged to respect those requests where reasonable.
`More considerations for the public <http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees>`__.
:xlarge:`Creative Commons Attribution 4.0 International Public License`
By exercising the Licensed Rights (defined below), You accept and agree to be
bound by the terms and conditions of this Creative Commons Attribution 4.0
International Public License ("Public License"). To the extent this Public
License may be interpreted as a contract, You are granted the Licensed Rights
in consideration of Your acceptance of these terms and conditions, and the
Licensor grants You such rights in consideration of benefits the Licensor
receives from making the Licensed Material available under these terms and
conditions.
Section 1 Definitions.
========================
a. **Adapted Material** means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material and in
which the Licensed Material is translated, altered, arranged, transformed, or
otherwise modified in a manner requiring permission under the Copyright and
Similar Rights held by the Licensor. For purposes of this Public License,
where the Licensed Material is a musical work, performance, or sound
recording, Adapted Material is always produced where the Licensed Material
is synched in timed relation with a moving image.
b. **Adapter's License** means the license You apply to Your Copyright and
Similar Rights in Your contributions to Adapted Material in accordance with
the terms and conditions of this Public License.
c. **Copyright and Similar Rights** means copyright and/or similar rights
closely related to copyright including, without limitation, performance,
broadcast, sound recording, and Sui Generis Database Rights, without regard
to how the rights are labeled or categorized. For purposes of this Public
License, the rights specified in Section 2(b)(1)-(2) are not Copyright and
Similar Rights.
d. **Effective Technological Measures** means those measures that, in the
absence of proper authority, may not be circumvented under laws fulfilling
obligations under Article 11 of the WIPO Copyright Treaty adopted on
December 20, 1996, and/or similar international agreements.
e. **Exceptions and Limitations** means fair use, fair dealing, and/or any
other exception or limitation to Copyright and Similar Rights that applies to
Your use of the Licensed Material.
f. **Licensed Material** means the artistic or literary work, database, or
other material to which the Licensor applied this Public License.
g. **Licensed Rights** means the rights granted to You subject to the terms
and conditions of this Public License, which are limited to all Copyright and
Similar Rights that apply to Your use of the Licensed Material and that the
Licensor has authority to license.
h. **Licensor** means the individual(s) or entity(ies) granting rights under
this Public License.
i. **Share** means to provide material to the public by any means or process
that requires permission under the Licensed Rights, such as reproduction,
public display, public performance, distribution, dissemination,
communication, or importation, and to make material available to the public
including in ways that members of the public may access the material from a
place and at a time individually chosen by them.
j. **Sui Generis Database Rights** means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of the
Council of 11 March 1996 on the legal protection of databases, as amended
and/or succeeded, as well as other essentially equivalent rights anywhere
in the world.
k. **You** means the individual or entity exercising the Licensed Rights
under this Public License. **Your** has a corresponding meaning.
Section 2 Scope.
==================
a. **License grant.**
1. Subject to the terms and conditions of this Public License, the Licensor
hereby grants You a worldwide, royalty-free, non-sublicensable,
non-exclusive, irrevocable license to exercise the Licensed Rights in the
Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part; and
B. produce, reproduce, and Share Adapted Material.
2. :underline:`Exceptions and Limitations.` For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public License does not
apply, and You do not need to comply with its terms and conditions.
3. :underline:`Term.` The term of this Public License is specified in Section 6(a).
4. :underline:`Media and formats`; :underline:`technical modifications allowed.` The Licensor
authorizes You to exercise the Licensed Rights in all media and formats
whether now known or hereafter created, and to make technical
modifications necessary to do so. The Licensor waives and/or agrees not to
assert any right or authority to forbid You from making technical
modifications necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective Technological
Measures. For purposes of this Public License, simply making modifications
authorized by this Section 2(a)(4) never produces Adapted Material.
5. :underline:`Downstream recipients.`
A. :underline:`Offer from the Licensor Licensed Material.` Every recipient of
the Licensed Material automatically receives an offer from the
Licensor to exercise the Licensed Rights under the terms and
conditions of this Public License.
B. :underline:`No downstream restrictions.` You may not offer or impose any
additional or different terms or conditions on, or apply any Effective
Technological Measures to, the Licensed Material if doing so restricts
exercise of the Licensed Rights by any recipient of the Licensed
Material.
6. :underline:`No endorsement.` Nothing in this Public License constitutes or may
be construed as permission to assert or imply that You are, or that Your
use of the Licensed Material is, connected with, or sponsored, endorsed,
or granted official status by, the Licensor or others designated to
receive attribution as provided in Section 3(a)(1)(A)(i).
b. **Other rights.**
1. Moral rights, such as the right of integrity, are not licensed under this
Public License, nor are publicity, privacy, and/or other similar
personality rights; however, to the extent possible, the Licensor waives
and/or agrees not to assert any such rights held by the Licensor to the
limited extent necessary to allow You to exercise the Licensed Rights, but
not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties
from You for the exercise of the Licensed Rights, whether directly or
through a collecting society under any voluntary or waivable statutory or
compulsory licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 License Conditions.
===============================
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. **Attribution.**
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the
Licensed Material:
i. identification of the creator(s) of the Licensed Material and any
others designated to receive attribution, in any reasonable manner
requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably
practicable;
B. indicate if You modified the Licensed Material and retain an
indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License,
and include the text of, or the URI or hyperlink to, this Public
License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner
based on the medium, means, and context in which You Share the Licensed
Material. For example, it may be reasonable to satisfy the conditions by
providing a URI or hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the information
required by Section 3(a)(1)(A) to the extent reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's License You apply
must not prevent recipients of the Adapted Material from complying with
this Public License.
Section 4 Sui Generis Database Rights.
========================================
Where the Licensed Rights include Sui Generis Database Rights that apply to Your
use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract,
reuse, reproduce, and Share all or a substantial portion of the contents of
the database;
b. if You include all or a substantial portion of the database contents in a
database in which You have Sui Generis Database Rights, then the database
in which You have Sui Generis Database Rights (but not its individual
contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share all or a
substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace
Your obligations under this Public License where the Licensed Rights include
other Copyright and Similar Rights.
Section 5 Disclaimer of Warranties and Limitation of Liability.
=================================================================
a. **Unless otherwise separately undertaken by the Licensor, to the extent
possible, the Licensor offers the Licensed Material as-is and as-available,
and makes no representations or warranties of any kind concerning the
Licensed Material, whether express, implied, statutory, or other. This
includes, without limitation, warranties of title, merchantability,
fitness for a particular purpose, non-infringement, absence of latent or
other defects, accuracy, or the presence or absence of errors, whether or
not known or discoverable. Where disclaimers of warranties are not allowed
in full or in part, this disclaimer may not apply to You.**
b. **To the extent possible, in no event will the Licensor be liable to You
on any legal theory (including, without limitation, negligence) or
otherwise for any direct, special, indirect, incidental, consequential,
punitive, exemplary, or other losses, costs, expenses, or damages arising
out of this Public License or use of the Licensed Material, even if the
Licensor has been advised of the possibility of such losses, costs, expenses,
or damages. Where a limitation of liability is not allowed in full or in
part, this limitation may not apply to You.**
c. The disclaimer of warranties and limitation of liability provided above
shall be interpreted in a manner that, to the extent possible, most
closely approximates an absolute disclaimer and waiver of all liability.
Section 6 Term and Termination.
=================================
a. This Public License applies for the term of the Copyright and Similar Rights
licensed here. However, if You fail to comply with this Public License, then
Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured
within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any right the
Licensor may have to seek remedies for Your violations of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material
under separate terms or conditions or stop distributing the Licensed Material
at any time; however, doing so will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 Other Terms and Conditions.
=======================================
a. The Licensor shall not be bound by any additional or different terms or
conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed
Material not stated herein are separate from and independent of the terms
and conditions of this Public License.
Section 8 Interpretation.
===========================
a. For the avoidance of doubt, this Public License does not, and shall not be
interpreted to, reduce, limit, restrict, or impose conditions on any use of
the Licensed Material that could lawfully be made without permission under
this Public License.
b. To the extent possible, if any provision of this Public License is deemed
unenforceable, it shall be automatically reformed to the minimum extent
necessary to make it enforceable. If the provision cannot be reformed, it
shall be severed from this Public License without affecting the
enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to
comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a
limitation upon, or waiver of, any privileges and immunities that apply to
the Licensor or You, including from the legal processes of any jurisdiction
or authority.
------------------
Creative Commons is not a party to its public licenses. Notwithstanding,
Creative Commons may elect to apply one of its public licenses to material it
publishes and in those instances will be considered the “Licensor.” Except for
the limited purpose of indicating that material is shared under a Creative
Commons public license or as otherwise permitted by the Creative Commons
policies published at `creativecommons.org/policies <http://creativecommons.org/policies>`__,
Creative Commons does not authorize the use of the trademark “Creative Commons”
or any other trademark or logo of Creative Commons without its prior written
consent including, without limitation, in connection with any unauthorized
modifications to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For the
avoidance of doubt, this paragraph does not form part of the public licenses.
Creative Commons may be contacted at `creativecommons.org <https://creativecommons.org/>`__

8
releaser/DEVELOPMENT.md Normal file
View File

@@ -0,0 +1,8 @@
# Releaser Development
- [pyTooling/pyAttributes](https://github.com/pyTooling/pyAttributes) or
[willmcgugan/rich](https://github.com/willmcgugan/rich) might be used to enhance the UX.
- It might be desirable to have pyTooling.Version.SemVersion handle the regular expression from
[semver.org](https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string), and use
proper Python classes in **Releaser**.

12
releaser/Dockerfile Normal file
View File

@@ -0,0 +1,12 @@
FROM python:3.9-slim-bullseye
COPY releaser.py /releaser.py
RUN pip install PyGithub --progress-bar off \
&& apt update -qq \
&& apt install -y curl \
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \
dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | \
tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt update -qq \
&& apt install -y gh
CMD ["/releaser.py"]

181
releaser/README.md Normal file
View File

@@ -0,0 +1,181 @@
# Releaser
**Releaser** is a Docker GitHub Action written in Python.
**Releaser** allows to keep a GitHub Release of type pre-release and its artifacts up to date with latest builds.
Combined with a workflow that is executed periodically, **Releaser** allows to provide a fixed release name for users willing
to use daily/nightly artifacts of a project.
Furthermore, when any [semver](https://semver.org) compilant tagged commit is pushed, **Releaser** can create a release
and upload assets.
## Context
GitHub provides official clients for the GitHub API through [github.com/octokit](https://github.com/octokit):
- [octokit.js](https://github.com/octokit/octokit.js) ([octokit.github.io/rest.js](https://octokit.github.io/rest.js))
- [octokit.rb](https://github.com/octokit/octokit.rb) ([octokit.github.io/octokit.rb](http://octokit.github.io/octokit.rb))
- [octokit.net](https://github.com/octokit/octokit.net) ([octokitnet.rtfd.io](https://octokitnet.rtfd.io))
When GitHub Actions was released in 2019, two Actions were made available through
[github.com/actions](https://github.com/actions) for dealing with GitHub Releases:
- [actions/create-release](https://github.com/actions/create-release)
- [actions/upload-release-asset](https://github.com/actions/upload-release-asset)
However, those Actions were contributed by an employee in spare time, not officially supported by GitHub.
Therefore, they were unmaintained before GitHub Actions was out of the private beta
(see [actions/upload-release-asset#58](https://github.com/actions/upload-release-asset/issues/58))
and, a year later, archived.
Those Actions are based on [actions/toolkit](https://github.com/actions/toolkit)'s hydrated version of octokit.js.
From a practical point of view, [actions/github-script](https://github.com/actions/github-script) is the natural replacement to those Actions, since it allows to use a pre-authenticated *octokit.js* client along with the workflow run context.
Still, it requires writing plain JavaScript.
Alternatively, there are non-official GitHub API libraries available in other languages (see [docs.github.com: rest/overview/libraries](https://docs.github.com/en/rest/overview/libraries)).
**Releaser** is based on [PyGithub/PyGithub](https://github.com/PyGithub/PyGithub), a Python client for the GitHub API.
**Releaser** was originally created in [eine/tip](https://github.com/eine/tip), as an enhanced alternative to using
`actions/create-release` and `actions/upload-release-asset`, in order to cover certain use cases that were being
migrated from Travis CI to GitHub Actions.
The main limitation of GitHub's Actions was/is verbosity and not being possible to dynamically define the list of assets
to be uploaded.
On the other hand, GitHub Actions artifacts do require login in order to download them.
Conversely, assets of GitHub Releases can be downloaded without login.
Therefore, in order to make CI results available to the widest audience, some projects prefer having tarballs available
as assets.
In this context, one of the main use cases of **Releaser** is pushing artifacts as release assets.
Thus, the name of the Action.
GitHub provides an official CLI tool, written in golang: [cli/cli](https://github.com/cli/cli).
When the Python version of **Releaser** was written, `cli` was evaluated as an alternative to *PyGitHub*.
`gh release` was (and still is) not flexible enough to update the reference of a release, without deleting and
recreating it (see [cli.github.com: manual/gh_release_create](https://cli.github.com/manual/gh_release_create)).
Deletion and recreation is unfortunate, because it notifies all the watchers of a repository
(see [eine/tip#111](https://github.com/eine/tip/issues/111)).
However, [cli.github.com: manual/gh_release_upload](https://cli.github.com/manual/gh_release_upload) handles uploading
artifacts as assets faster and with better stability for larger files than *PyGitHub*
(see [msys2/msys2-installer#36](https://github.com/msys2/msys2-installer/pull/36)).
Furthermore, the GitHub CLI is installed on GitHub Actions' default virtual environments.
Although `gh` does not support login through SSH (see [cli/cli#3715](https://github.com/cli/cli/issues/3715)), on GitHub
Actions a token is available `${{ github.token }}`.
Therefore, **Releaser** uses `gh release upload` internally.
## Usage
The following block shows a minimal YAML workflow file:
```yml
name: 'workflow'
on:
schedule:
- cron: '0 0 * * 5'
jobs:
mwe:
runs-on: ubuntu-latest
steps:
# Clone repository
- uses: actions/checkout@v2
# Build your application, tool, artifacts, etc.
- name: Build
run: |
echo "Build some tool and generate some artifacts" > artifact.txt
# Update tag and pre-release
# - Update (force-push) tag to the commit that is used in the workflow.
# - Upload artifacts defined by the user.
- uses: pyTooling/Actions/releaser@r0
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
artifact.txt
README.md
```
### Composite Action
The default implementation of **Releaser** is a Container Action.
Therefore, a pre-built container image is pulled before starting the job.
Alternatively, a Composite Action version is available: `uses: pyTooling/Actions/releaser/composite@main`.
The Composite version installs the dependencies on the host (the runner environment), instead of using a container.
Both implementations are functionally equivalent from **Releaser**'s point of view; however, the Composite Action allows
users to tweak the version of Python by using [actions/setup-python](https://github.com/actions/setup-python) before.
## Options
All options can be optionally provided as environment variables: `INPUT_TOKEN`, `INPUT_FILES`, `INPUT_TAG`, `INPUT_RM`
and/or `INPUT_SNAPSHOTS`.
### token (required)
Token to make authenticated API calls; can be passed in using `{{ secrets.GITHUB_TOKEN }}`.
### files (required)
Either a single filename/pattern or a multi-line list can be provided. All the artifacts are uploaded regardless of the
hierarchy.
For creating/updating a release without uploading assets, set `files: none`.
### tag
The default tag name for the tip/nightly pre-release is `tip`, but it can be optionally overriden through option `tag`.
### rm
Set option `rm` to `true` for systematically removing previous artifacts (e.g. old versions).
Otherwise (by default), all previours artifacts are preserved or overwritten.
Note:
If all the assets are removed, or if the release itself is removed, tip/nightly assets won't be available for
users until the workflow is successfully run.
For instance, Action [setup-ghdl-ci](https://github.com/ghdl/setup-ghdl-ci) uses assets from [ghdl/ghdl: releases/tag/nightly](https://github.com/ghdl/ghdl/releases/tag/nightly).
Hence, it is recommended to try removing the conflictive assets only, in order to maximise the availability.
### snapshots
Whether to create releases from any tag or to treat some as snapshots.
By default, all the tags with non-empty `prerelease` field (see [semver.org: Is there a suggested regular expression (RegEx) to check a SemVer string?](https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string))
are considered snapshots; neither a release is created nor assets are uploaded.
## Advanced/complex use cases
**Releaser** is essentially a very thin wrapper to use the GitHub Actions context data along with the classes
and methods of PyGithub.
Similarly to [actions/github-script](https://github.com/actions/github-script), users with advanced/complex requirements
might find it desirable to write their own Python script, instead of using **Releaser**.
In fact, since `shell: python` is supported in GitHub Actions, using Python does *not* require any Action.
For prototyping purposes, the following job might be useful:
```yml
Release:
name: '📦 Release'
runs-on: ubuntu-latest
needs:
- ...
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/'))
steps:
- uses: actions/download-artifact@v2
- shell: bash
run: pip install PyGithub --progress-bar off
- name: Set list of files for uploading
id: files
shell: python
run: |
from github import Github
print("· Get GitHub API handler (authenticate)")
gh = Github('${{ github.token }}')
print("· Get Repository handler")
gh_repo = gh.get_repo('${{ github.repository }}')
```
Find a non-trivial use case at [msys2/msys2-autobuild](https://github.com/msys2/msys2-autobuild).

45
releaser/action.yml Normal file
View File

@@ -0,0 +1,45 @@
# ==================================================================================================================== #
# Authors: #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: 'Releaser'
description: 'Publish releases, upload assets and update tip/nightly tags'
inputs:
token:
description: 'Token to make authenticated API calls; can be passed in using {{ secrets.GITHUB_TOKEN }}'
required: true
files:
description: 'Multi-line list of glob patterns describing the artifacts to be uploaded'
required: true
tag:
description: 'Name of the tag that corresponds to the tip/nightly pre-release'
required: false
default: tip
rm:
description: 'Whether to delete all the previous artifacts, or only replacing the ones with the same name'
required: false
default: false
snapshots:
description: 'Whether to create releases from any tag or to treat some as snapshots'
required: false
default: true
runs:
using: 'docker'
image: 'docker://ghcr.io/pytooling/releaser'

View File

@@ -0,0 +1,57 @@
# ==================================================================================================================== #
# Authors: #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: 'Releaser'
description: 'Publish releases, upload assets and update tip/nightly tags'
inputs:
token:
description: 'Token to make authenticated API calls; can be passed in using {{ secrets.GITHUB_TOKEN }}'
required: true
files:
description: 'Multi-line list of glob patterns describing the artifacts to be uploaded'
required: true
tag:
description: 'Name of the tag that corresponds to the tip/nightly pre-release'
required: false
default: tip
rm:
description: 'Whether to delete all the previous artifacts, or only replacing the ones with the same name'
required: false
default: false
snapshots:
description: 'Whether to create releases from any tag or to treat some as snapshots'
required: false
default: true
runs:
using: 'composite'
steps:
- shell: bash
run: pip install PyGithub --progress-bar off
- shell: bash
run: '''${{ github.action_path }}/../releaser.py'''
env:
INPUT_TOKEN: ${{ inputs.token }}
INPUT_FILES: ${{ inputs.files }}
INPUT_TAG: ${{ inputs.tag }}
INPUT_RM: ${{ inputs.rm }}
INPUT_SNAPSHOTS: ${{ inputs.snapshots }}

2
releaser/pyproject.toml Normal file
View File

@@ -0,0 +1,2 @@
[tool.black]
line-length = 120

193
releaser/releaser.py Executable file
View File

@@ -0,0 +1,193 @@
#!/usr/bin/env python3
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
import re
from sys import argv as sys_argv, stdout, exit as sys_exit
from os import environ, getenv
from glob import glob
from pathlib import Path
from github import Github, GithubException
from subprocess import check_call
paramTag = getenv("INPUT_TAG", "tip")
paramFiles = getenv("INPUT_FILES", None).split()
paramRM = getenv("INPUT_RM", "false") == "true"
paramSnapshots = getenv("INPUT_SNAPSHOTS", "true").lower() == "true"
paramToken = (
environ["GITHUB_TOKEN"]
if "GITHUB_TOKEN" in environ
else environ["INPUT_TOKEN"]
if "INPUT_TOKEN" in environ
else None
)
paramRepo = getenv("GITHUB_REPOSITORY", None)
paramRef = getenv("GITHUB_REF", None)
paramSHA = getenv("GITHUB_SHA", None)
def GetListOfArtifacts(argv, files):
print("· Get list of artifacts to be uploaded")
args = files if files is not None else []
if len(argv) > 1:
args += argv[1:]
if len(args) == 1 and args[0].lower() == "none":
print("! Skipping 'files' because it's set to 'none'.")
return []
elif len(args) == 0:
stdout.flush()
raise (Exception("Glob patterns need to be provided as positional arguments or through envvar 'INPUT_FILES'!"))
else:
flist = []
for item in args:
print(f" glob({item!s}):")
for fname in [fname for fname in glob(item, recursive=True) if not Path(fname).is_dir()]:
if Path(fname).stat().st_size == 0:
print(f" - ! Skipping empty file {fname!s}.")
continue
print(f" - {fname!s}")
flist.append(fname)
if len(flist) < 1:
stdout.flush()
raise (Exception("Empty list of files to upload/update!"))
return sorted(flist)
def GetGitHubAPIHandler(token):
print("· Get GitHub API handler (authenticate)")
if token is not None:
return Github(token)
raise (Exception("Need credentials to authenticate! Please, provide 'GITHUB_TOKEN' or 'INPUT_TOKEN'"))
def CheckRefSemVer(gh_ref, tag, snapshots):
print("· Check SemVer compliance of the reference/tag")
env_tag = None
if gh_ref[0:10] == "refs/tags/":
env_tag = gh_ref[10:]
if env_tag != tag:
rexp = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
semver = re.search(rexp, env_tag)
if semver == None and env_tag[0] == "v":
semver = re.search(rexp, env_tag[1:])
tag = env_tag
if semver == None:
print(f"! Could not get semver from {gh_ref!s}")
print(f"! Treat tag '{tag!s}' as a release")
return (tag, env_tag, False)
else:
if semver.group("prerelease") is None:
# is a regular semver compilant tag
return (tag, env_tag, False)
elif snapshots:
# is semver compilant prerelease tag, thus a snapshot (we skip it)
print("! Skipping snapshot prerelease.")
sys_exit()
return (tag, env_tag, True)
def GetRepositoryHandler(gh, repo):
print("· Get Repository handler")
if repo is None:
stdout.flush()
raise (Exception("Repository name not defined! Please set 'GITHUB_REPOSITORY"))
return gh.get_repo(repo)
def GetOrCreateRelease(gh_repo, tag, sha, is_prerelease):
print("· Get Release handler")
gh_tag = None
try:
gh_tag = gh_repo.get_git_ref(f"tags/{tag!s}")
except Exception:
stdout.flush()
if gh_tag:
try:
return (gh_repo.get_release(tag), False)
except Exception:
return (gh_repo.create_git_release(tag, tag, "", draft=True, prerelease=is_prerelease), True)
else:
err_msg = f"Tag/release '{tag!s}' does not exist and could not create it!"
if sha is None:
raise (Exception(err_msg))
try:
return (
gh_repo.create_git_tag_and_release(
tag, "", tag, "", sha, "commit", draft=True, prerelease=is_prerelease
),
True,
)
except Exception:
raise (Exception(err_msg))
def UpdateReference(gh_release, tag, sha, is_prerelease, is_draft):
print("· Update Release reference (force-push tag)")
if is_draft:
# Unfortunately, it seems not possible to update fields 'created_at' or 'published_at'.
print(" > Update (pre-)release")
gh_release.update_release(
gh_release.title,
"" if gh_release.body is None else gh_release.body,
draft=False,
prerelease=is_prerelease,
tag_name=gh_release.tag_name,
target_commitish=gh_release.target_commitish,
)
if sha is not None:
print(f" > Force-push '{tag!s}' to {sha!s}")
gh_repo.get_git_ref(f"tags/{tag!s}").edit(sha)
files = GetListOfArtifacts(sys_argv, paramFiles)
stdout.flush()
[tag, env_tag, is_prerelease] = CheckRefSemVer(paramRef, paramTag, paramSnapshots)
stdout.flush()
gh_repo = GetRepositoryHandler(GetGitHubAPIHandler(paramToken), paramRepo)
stdout.flush()
[gh_release, is_draft] = GetOrCreateRelease(gh_repo, tag, paramSHA, is_prerelease)
stdout.flush()
if paramRM:
print("· RM set. All previous assets are being cleared...")
for asset in gh_release.get_assets():
print(f" - {asset.name}")
asset.delete_asset()
stdout.flush()
if len(files) > 0:
print("· Upload assets")
env = environ.copy()
env["GITHUB_TOKEN"] = paramToken
cmd = ["gh", "release", "upload", "--repo", paramRepo, "--clobber", tag] + files
print(f" > {' '.join(cmd)}")
check_call(cmd, env=env)
stdout.flush()
else:
print("! Skipping uploading assets because the file list is empty.")
UpdateReference(gh_release, tag, paramSHA if env_tag is None else None, is_prerelease, is_draft)

View File

@@ -1,5 +1,29 @@
# ==================================================================================================================== #
# Authors: #
# Patrick Lehmann #
# Unai Martinez-Corral #
# #
# ==================================================================================================================== #
# Copyright 2020-2022 The pyTooling Authors #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# SPDX-License-Identifier: Apache-2.0 #
# ==================================================================================================================== #
name: With post step
description: 'Generic JS Action to execute a main command and set a command as a post step.'
inputs:
main:
description: 'Main command/script.'
@@ -11,7 +35,8 @@ inputs:
description: 'Name of the state variable used to detect the post step.'
required: false
default: POST
runs:
using: 'node12'
using: 'node16'
main: 'main.js'
post: 'main.js'

View File

@@ -1,36 +1,38 @@
// Authors:
// Unai Martinez-Corral
//
// Copyright 2021 Unai Martinez-Corral <unai.martinezcorral@ehu.eus>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
// Context:
// * https://github.com/docker/login-action/issues/72
// * https://github.com/actions/runner/issues/1478
const { exec } = require("child_process");
/* ================================================================================================================== *
* Authors: *
* Unai Martinez-Corral *
* *
* ================================================================================================================== *
* Copyright 2021-2022 Unai Martinez-Corral <unai.martinezcorral@ehu.eus> *
* Copyright 2022 Unai Martinez-Corral <umartinezcorral@antmicro.com> *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
* SPDX-License-Identifier: Apache-2.0 *
* ================================================================================================================== *
* *
* Context: *
* * https://github.com/docker/login-action/issues/72 *
* * https://github.com/actions/runner/issues/1478 *
* ================================================================================================================== */
const { spawn } = require("child_process");
const { appendFileSync } = require("fs");
const { EOL } = require("os");
function run(cmd) {
exec(cmd, (error, stdout, stderr) => {
if ( stdout.length !== 0 ) { console.log(`${stdout}`); }
if ( stderr.length !== 0 ) { console.error(`${stderr}`); }
if (error) {
process.exitCode = error.code;
console.error(`${error}`);
}
const subprocess = spawn(cmd, { stdio: "inherit", shell: true });
subprocess.on("exit", (exitCode) => {
process.exitCode = exitCode;
});
}
@@ -39,6 +41,6 @@ const key = process.env.INPUT_KEY.toUpperCase();
if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step?
run(process.env.INPUT_POST);
} else { // Otherwise, this is the main step
console.log(`::save-state name=${key}::true`);
appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`);
run(process.env.INPUT_MAIN);
}