Commit 2d6db65
authored
[CI] Refactor GHA workflow for cog unit tests (#673)
* [CI] Rework cog unit test to be aware of cog-specific deps
This creates a new GH Actions workflow that replace the existing
`cogUnitTests.yml`. It basically generates a `tox.ini` with
`testenv`s corresponding to all cogs, with cog-specific deps, and
run all tests within their directories. The workflow file also
allows for easy Red bot (upstream) version anchoring, as well as
having only tests for specific cogs run on `workflow_dispatch`.
* [CI] Fix formatting for `gen_tox_ini.py`
* [CI] Fix `Red-DiscordBot` tag in `cog_unit_test.yaml`
There is no `v` prefix.
* [CI] Make workflow cog unit test look at `cogs` dir
This commit adds great flexibility to generator scripts and adjust the
`cog_unit_test.yaml` workflow file to specify the cogs dir ("cogs") and
INI template file paths.
* [CI] Use `cog_` prefix for `tox` envs in cog unit test
* [CI] Add a step in cog unit test workflow to show generated configs
This helps with debugging.
* [CI] Empty `requirements.txt` if `requirements` is not in `info.json`
* [CI] Set name for the "set matrix output" step in cog unit test
* [CI] Account for cogs without `info.json` in cog unit test
* [CI] Let `tox` install Red deps directly via `git`
* [CI] Fix `tox` Git dep path in cog unit test `tox.ini` template
It is not supposed to be prefixed with `-r`.
* [CI] Simplify and use absolute path for cogs dir
This commit renders templates redundant. Tox env var substitution is
enough to get the job done.
* [CI] Correct INI paths in cog unit test workflow
* [CI] Install Red dev deps in cog unit test workflow
This is done just to get Red's development dependencies `pytest` and
`tox`.
* [CI] Remove `#egg` in package URL and install `tox`
It turns out that `tox` is not included when installing
`red-discordbot[dev]`.
Also, `#egg` is deprecated.
See pypa/pip#13157 for more details.
* [CI] Use absolute paths for all paths in env in cog unit test workflow
* [CI] Allow cogs with no tests to pass in cog unit test workflow
* [CI] Ignore Pytest's exit code 5 in cog unit test workflow
This exit code is used when Pytest does not find any tests.
* [CI] Use extra target `test` instead of `dev` from `red-discordbot`
`dev` will try to drag in `sphinx-prompt` 1.7.0 which is not compatible
with Python 3.11.
* [CI] Let tox allow bash and sh in cog unit test workflow
* [CI] Use absolute paths in tox's `allowlist_externals`
* [CI] Skip installing `red-discordbot` in cog unit test workflow
Only `tox` is needed, and then `tox`, upon installing
`red-discordbot[test]`, will use that environment to run `pytest`.
* [CI] Simplify `workflow_dispatch` for cog unit test workflow
If the ability to input cog names for manual runs is wanted later, it
can then be implemented.
Also, this commit cleans up the `discover` job and removes the
installing of `jq` in `test` job. `jq` is available already.
* [CI] Make `jq` output JSON list in one line in cog unit test workflow
Without this, GitHub will run into this error:
"Unable to process file command 'output' successfully."
* [CI] Inline env vars in cog unit test workflow
Except for `COGS_PATH`, all other environment variables can be inlined.
* [CI] Exclude the cogs dir passed into `find` in cog unit test workflow
This is a `find` gotcha. The flag `-mindepth 1` has to be there to fix
this.
* [CI] Extract and use Red version from `setup.py`
* [CI] Clean up env vars in cog unit test workflow
This commit also utilizes `COGS_REL_PATH` in `hashFiles` so that there
is no longer the hardcoded `cogs` dir in `hashFiles` anymore.
* [CI] Remove the "empty" comment in `jq` in cog unit test workflow
* [CI] Collect only testful cogs in cog unit test workflow
This commit relies on Pytest's test collection logic to extract the
names of the cogs with tests. Tox is used to keep the
`red-discordbot[test]` base dependency central in one INI file. Cogs
with no tests will not be included in the `cogs` output of the
`discover` job, meaning they will not get recognized by the `test` job.
* [CI] Fix the `run` field of `collect-testful-cogs`
* [CI] Correct `--cogs-dir` to `--cogs-path` in `cog_unit_test_tox.ini`
* [CI] Rename `SCRIPT_PATH` to `SCRIPT_PY` in `cog_unit_test_tox.ini`
It is simply because other envs and flags (like `PYTEST_INI`) end with
their known extensions.1 parent 1ab21e6 commit 2d6db65
File tree
5 files changed
+190
-26
lines changed- .github/workflows
- configs
- scripts
5 files changed
+190
-26
lines changedThis file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
0 commit comments