diff --git a/.github/workflows/ci-builtin.yml b/.github/workflows/ci-builtin.yml index 8ec78fd..1847a04 100644 --- a/.github/workflows/ci-builtin.yml +++ b/.github/workflows/ci-builtin.yml @@ -2,8 +2,10 @@ name: '๐Ÿ” CI (built-in matrix)' on: push -# This is action code check, action integration test and advanced usage example -# at the same time. +# This workflow serves for multiple purposes: +# - Action code check +# - Action integration test +# - Advanced usage example (reusable matrix) jobs: # Check code formatting diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index daffb5d..731cdc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,10 @@ name: '๐Ÿ” CI' on: push -# This is action code check, action integration test and advanced usage example -# at the same time. +# This workflow serves for multiple purposes: +# - Action code check +# - Action integration test +# - Advanced usage example (reusable matrix) jobs: # Setup matrix diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index d74bde0..ad9e965 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -6,11 +6,12 @@ on: - cron: '0 6 * * *' workflow_dispatch: -# This is action code test, action integration test and usage example -# at the same time. +# This workflow serves for multiple purposes: +# - Action integration test +# - Usage example jobs: - # Setup matrix + # Valid jobs setup-matrix-multi-line: runs-on: ubuntu-latest outputs: @@ -35,6 +36,7 @@ jobs: - uses: druzsan/setup-matrix@feature/use-python-dockerfile with: matrix: '{ os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] }' + # Jobs expected to fail setup-matrix-empty: runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/quickstart.yml b/.github/workflows/quickstart.yml index 2836525..6545318 100644 --- a/.github/workflows/quickstart.yml +++ b/.github/workflows/quickstart.yml @@ -6,7 +6,9 @@ on: - cron: '0 6 * * *' workflow_dispatch: -# This is action integration test and quickstart example at the same time. +# This workflow serves for multiple purposes: +# - Action integration test +# - Quickstart example jobs: # Setup matrix diff --git a/.github/workflows/test-builtin.yml b/.github/workflows/unit-test-builtin.yml similarity index 91% rename from .github/workflows/test-builtin.yml rename to .github/workflows/unit-test-builtin.yml index 5c717c3..edaf6cc 100644 --- a/.github/workflows/test-builtin.yml +++ b/.github/workflows/unit-test-builtin.yml @@ -1,9 +1,11 @@ -name: '๐Ÿงช Test (built-in matrix)' +name: '๐Ÿงช Unit Test (built-in matrix)' on: push -# This is action code test, action integration test and advanced usage example -# at the same time. +# This workflow serves for multiple purposes: +# - Action code test +# - Action integration test +# - Advanced usage example (dynamic matrix) jobs: # Run unit-test on a dev branch diff --git a/.github/workflows/test.yml b/.github/workflows/unit-test.yml similarity index 92% rename from .github/workflows/test.yml rename to .github/workflows/unit-test.yml index 393ed26..781f544 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/unit-test.yml @@ -1,4 +1,4 @@ -name: '๐Ÿงช Test' +name: '๐Ÿงช Unit Test' on: push: @@ -6,8 +6,10 @@ on: - cron: '0 6 * * *' workflow_dispatch: -# This is action code test, action integration test and advanced usage example -# at the same time. +# This workflow serves for multiple purposes: +# - Action code test +# - Action integration test +# - Advanced usage example (dynamic matrix) jobs: # Setup matrix diff --git a/README.md b/README.md index 4e46b41..e0481c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # โœ‰๏ธ Setup matrix -[![โฑ๏ธ Quickstart](https://github.com/druzsan/setup-matrix/actions/workflows/quickstart.yml/badge.svg)](https://github.com/druzsan/setup-matrix/actions/workflows/quickstart.yml) [![๐Ÿ” CI](https://github.com/druzsan/setup-matrix/actions/workflows/ci.yml/badge.svg)](https://github.com/druzsan/setup-matrix/actions/workflows/ci.yml) [![๐Ÿงช Test](https://github.com/druzsan/setup-matrix/actions/workflows/test.yml/badge.svg)](https://github.com/druzsan/setup-matrix/actions/workflows/test.yml) +[![โฑ๏ธ Quickstart](https://github.com/druzsan/setup-matrix/actions/workflows/quickstart.yml/badge.svg)](https://github.com/druzsan/setup-matrix/actions/workflows/quickstart.yml) [![๐Ÿ” CI](https://github.com/druzsan/setup-matrix/actions/workflows/ci.yml/badge.svg)](https://github.com/druzsan/setup-matrix/actions/workflows/ci.yml) [![๐Ÿงช Unit Test](https://github.com/druzsan/setup-matrix/actions/workflows/test.yml/badge.svg)](https://github.com/druzsan/setup-matrix/actions/workflows/test.yml) [![๐Ÿงช Integration Test](https://github.com/druzsan/setup-matrix/actions/workflows/integration-test.yml/badge.svg)](https://github.com/druzsan/setup-matrix/actions/workflows/integration-test.yml) GitHub action to create reusable dynamic job matrices for your workflows. @@ -59,11 +59,12 @@ For more examples, see [advanced usage](#advanced-usage) Action has only one required input `matrix`, whose syntax is exactly the same as the built-in matrix provided as string. -Full YAML syntax is supported inside input, so you even can add comments which will be ignored during parsing. +Full YAML syntax is supported inside input, so you even can add inline comments which will be ignored during parsing. It is highly recommended to use `|` prefix for multi-line strings: ```yaml +uses: druzsan/setup-matrix@v2 with: matrix: | # Setup matrix with OS and Python version os: [ubuntu-latest, windows-latest] @@ -79,9 +80,9 @@ with: Flow YAML syntax is also supported: ```yaml +uses: druzsan/setup-matrix@v2 with: - matrix: - { os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] } + matrix: '{ os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] }' ``` ## Outputs @@ -96,23 +97,20 @@ valid JSON matrix ready to be set as `jobs..outputs` used in `jobs..strategy`: ```yaml -matrix: ${{ fromJson(needs..outputs.matrix) }} +strategy: + matrix: ${{ fromJson(needs..outputs.matrix) }} ``` ## Errors -Not only syntax validity, but also built-in matrix' restrictions are checked. If -you find a case where either of the checks does not work, feel free to report as -an issue. +Not only syntax validity, but also built-in matrix restrictions (e.g. empty resulting matrix) are checked. Error logs try to give as much infomation on problem as possible. -Error logs try to give as much infomation on problem as possible. +## Advanced Usage -## Advanced usage - -### Reuse a matrix +### Reusable Matrix Sometimes you need to run different jobs on the same set of configurations, e.g. -install python dependencies, check code quality and run unit tests. +check code formatting, code types and lint code.
Solution using the built-in matrix @@ -231,7 +229,7 @@ jobs: - run: python -m pytest ``` -### Setup dynamic matrix +### Dynamic Matrix Sometimes you need to run a job on different sets of configurations, depending on branch, triggering event etc. @@ -341,9 +339,4 @@ jobs: ## Limitations -[Parsing](./parse-matrix.sh) the input is written in bash using sed, grep and -jq, so running on an Ubuntu runner is mandatory. - -There is currently no way to pass multiline strings or strings containing colons -and/or commas as variable names or values. If you need to have such strings -please open an issue. +Since the action uses Python and Dockerfile, is is mandatory to run it on an Ubuntu runner.