From 4d758e89f51d62d890241033c83a4a23b1617eab Mon Sep 17 00:00:00 2001 From: Bryan Naegele Date: Sun, 12 Sep 2021 18:49:05 -0600 Subject: [PATCH] Update test matrix strategy (#10) --- .github/test-matrix.json | 27 +++++++++++++++++----- .github/workflows/elixir.yml | 43 ++++++++++++++---------------------- CONTRIBUTING.md | 18 +++++++++++++++ 3 files changed, 55 insertions(+), 33 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/.github/test-matrix.json b/.github/test-matrix.json index 8093158..11fc6bf 100644 --- a/.github/test-matrix.json +++ b/.github/test-matrix.json @@ -1,20 +1,35 @@ { - "otp_version": ["24.0.4", "23.3.4.2", "22.3.4.20"], - "elixir_version": ["1.12.2", "1.11.4", "1.10.4"], + "otp_version": [ + "24.0.6", + "23.3.4.7", + "22.3.4.21" + ], + "elixir_version": [ + "1.12.3", + "1.11.4" + ], + "rebar3_version": [ + "3.16.1" + ], + "os": [ + "ubuntu-18.04" + ], "include": [ { "otp_version": "21.3.8.24", "elixir_version": "1.10.4", "rebar3_version": "3.15.2" + }, + { + "otp_version": "21.3.8.24", + "elixir_version": "1.11.4", + "rebar3_version": "3.15.2" } ], "exclude": [ { "otp_version": "21.3.8.24", - "elixir_version": "1.12.2" + "elixir_version": "1.12.3" } - ], - "apps": [ - "opentelemetry_phoenix" ] } diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 151e0ef..4f9bcc0 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -10,19 +10,22 @@ on: - 'main' jobs: - # test-matrix: - # runs-on: ubuntu-latest - # outputs: - # matrix: ${{ steps.set-matrix.outputs.matrix }} - # steps: - # - uses: actions/checkout@v2 - # - name: Read file - # id: set-matrix - # run: | - # echo "::set-output name=matrix::$(cat ./.github/test-matrix.json | jq -r -s '.|tojson')" + test-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + - name: Read file + id: set-matrix + run: | + matrixStringifiedObject="{\"otp_version\":[\"24.0.6\",\"23.3.4.7\",\"22.3.4.21\"],\"elixir_version\":[\"1.12.3\",\"1.11.4\"],\"rebar3_version\":[\"3.16.1\"],\"os\":[\"ubuntu-18.04\"],\"include\":[{\"otp_version\":\"21.3.8.24\",\"elixir_version\":\"1.10.4\",\"rebar3_version\":\"3.15.2\"},{\"otp_version\":\"21.3.8.24\",\"elixir_version\":\"1.11.4\",\"rebar3_version\":\"3.15.2\"}],\"exclude\":[{\"otp_version\":\"21.3.8.24\",\"elixir_version\":\"1.12.3\"}]}" + echo "::set-output name=matrix::$matrixStringifiedObject" opentelemetry-phoenix: - # needs: [test-matrix] - if: (contains(github.event.pull_request.labels.*.name, 'elixir') && contains(github.event.pull_request.labels.*.name, 'opentelemetry_phoenix')) + needs: [test-matrix] + if: (contains(github.event.pull_request.labels.*.name, 'elixir') && contains(github.event.pull_request.labels.*.name, 'opentelemetry_phoenix') && contains(github.event.pull_request.labels.*.name, 'scope-ci')) + env: + app: 'opentelemetry_phoenix' defaults: run: working-directory: instrumentation/${{ env.app }} @@ -30,21 +33,7 @@ jobs: name: Opentelemetry Phoenix test on Elixir ${{ matrix.elixir_version }} (OTP ${{ matrix.otp_version }}) strategy: fail-fast: false - matrix: - os: [ubuntu-18.04] - otp_version: ["24.0.4", "23.3.4.2", "22.3.4.20"] - elixir_version: ["1.12.2", "1.11.4"] - rebar3_version: ["3.16.1"] - include: - - otp_version: '21.3.8.24' - elixir_version: '1.11.4' - rebar3_version: '3.15.2' - os: ubuntu-18.04 - exclude: - - otp_version: '21.3.8.24' - elixir_version: '1.12.1' - env: - app: 'opentelemetry_phoenix' + matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }} steps: - uses: actions/checkout@v2 - uses: erlef/setup-beam@v1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c3a15bf --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,18 @@ +## Contributing + + +### CI + +Given the number of projects in this repo and the wide matrix of OTP/Elixir versions we must +test against, it is important to scope test jobs to the smallest subset of test possible. Project test jobs should utilize the test matrix strategy outputted by the `test-matrix` job. + +### Test Matrix Updates + +As new OTP and Elixir versions are released, the test matrix must be updated. A beautified version of the [test matrix](https://github.com/open-telemetry/opentelemetry-erlang-contrib/blob/main/.github/test-matrix.json) is kept for easy editing. + +Updating the file: + +1. Update the beautified json file (this is the form you'll commit) +2. Uglify and escape the json object +3. Copy this final value to the `test-matrix` job output +