From 390ab1e418af6aa245d5e1d8bcd3a585af463f68 Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 21 Jan 2022 18:59:52 +0300 Subject: [PATCH 01/21] propose erlang reusable workflow --- .github/workflows/erlang-parallel-build.yml | 185 ++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 .github/workflows/erlang-parallel-build.yml diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml new file mode 100644 index 0000000..9fca6f1 --- /dev/null +++ b/.github/workflows/erlang-parallel-build.yml @@ -0,0 +1,185 @@ +name: Erlang Parallel Build + +on: + workflow_call: + inputs: + service-name: + description: 'Service name, as in docker-compose.yml (only required when running when run-ct-with-compose: true).' + required: false + default: "" + type: string + otp-version: + description: 'Erlang/OTP version to use.' + required: true + type: string + rebar-version: + description: 'Rebar version to use.' + required: true + type: string + thrift-version: + description: 'Thrift (valitydev/thrift) version to use.' + required: true + type: string + run-ct-with-compose: + description: 'Run tests in a docker-compose environment, requires a docker-compose.yml file (see `valitydev/erlang-templates` for examples).' + required: false + default: false + type: boolean + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ inputs.otp-version }} + rebar3-version: ${{ inputs.rebar-version }} + + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/*/lib + key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + + - name: Compile + run: rebar3 compile + + check: + name: Check + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ inputs.otp-version }} + rebar3-version: ${{ inputs.rebar-version }} + + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/*/lib + key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + + - name: Check formatting + run: rebar3 fmt -c + + - name: Run linting + run: rebar3 lint + + - name: Run xref + run: rebar3 xref + + dialyze: + name: Dialyze + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ inputs.otp-version }} + rebar3-version: ${{ inputs.rebar-version }} + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.5 + with: + thrift-version: ${{ inputs.thrift-version }} + + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/*/lib + key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + + - name: Cache PLTs + uses: actions/cache@v2 + with: + path: _build/test/rebar3_*_plt + key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-plt-${{ hashFiles('rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ inputs.otp-version }}-plt- + + - name: Run dialyzer + run: rebar3 dialyzer + + test: + name: Test + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup BEAM + uses: erlef/setup-beam@v1.10 + with: + otp-version: ${{ inputs.otp-version }} + rebar3-version: ${{ inputs.rebar-version }} + + - name: Cache _build + uses: actions/cache@v2 + with: + path: _build/*/lib + key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + restore-keys: | + ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + + - name: Setup Thrift compiler + uses: valitydev/action-setup-thrift@v0.0.5 + with: + thrift-version: ${{ inputs.thrift-version }} + + - name: Run EUnit + run: rebar3 eunit --cover + + - name: Run CommonTest + id: run-ct + if: ${{ inputs.run-ct-with-compose == false }} + run: rebar3 ct --cover + + - name: Run CommonTest (/w docker-compose) + id: run-ct-w-compose + if: ${{ inputs.run-ct-with-compose == true }} + env: + DEV_IMAGE_TAG: ${{ inputs.service-name }}-dev + OTP_VERSION: ${{ inputs.otp-version }} + THRIFT_VERSION: ${{ inputs.thrift-version }} + COMPOSE_DOCKER_CLI_BUILD: true + DOCKER_BUILDKIT: true + run: | + [[ "${{ inputs.service-name }}" == "" ]] && exit 1 + docker-compose run --use-aliases --rm ${{ inputs.service-name }} rebar3 ct --cover + + - name: Store CT Logs + if: ${{ failure() && (steps.run-ct.outcome == 'failure' || steps.run-ct-w-compose.outcome == 'failure') }} + uses: actions/upload-artifact@v2 + with: + name: ct-logs + path: _build/test/logs + + - name: Run test coverage analysis + run: rebar3 covertool generate + + - name: Upload coverage statistics + uses: codecov/codecov-action@v2 + with: + fail_ci_if_error: true + files: _build/test/covertool/*.covertool.xml From fe5a4d43b244800daa3efbd2dc1e5335eb65dc8f Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 21 Jan 2022 19:36:15 +0300 Subject: [PATCH 02/21] dialyzer as test --- .github/workflows/erlang-parallel-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 9fca6f1..989cfcd 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -118,7 +118,7 @@ jobs: ${{ runner.os }}-otp-${{ inputs.otp-version }}-plt- - name: Run dialyzer - run: rebar3 dialyzer + run: rebar3 as test dialyzer test: name: Test From acbc73d39b4dd630d9c797ddaeb8af92fb071014 Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 21 Jan 2022 19:45:21 +0300 Subject: [PATCH 03/21] some comments --- .github/workflows/erlang-parallel-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 989cfcd..9862330 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -159,9 +159,11 @@ jobs: id: run-ct-w-compose if: ${{ inputs.run-ct-with-compose == true }} env: + # Pass workflow params to use in docker-compose.yml DEV_IMAGE_TAG: ${{ inputs.service-name }}-dev OTP_VERSION: ${{ inputs.otp-version }} THRIFT_VERSION: ${{ inputs.thrift-version }} + # Enable buildkit extensions in docker compose COMPOSE_DOCKER_CLI_BUILD: true DOCKER_BUILDKIT: true run: | From 7629f0e5e38aaf5c6ed8713af1f6a45dbc70d984 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 26 Jan 2022 14:44:58 +0300 Subject: [PATCH 04/21] better build env, swagger codegen support --- .../actions/setup-swagger-codegen/action.yml | 37 +++++++++++++ .github/workflows/erlang-parallel-build.yml | 54 ++++++++++++++----- 2 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 .github/actions/setup-swagger-codegen/action.yml diff --git a/.github/actions/setup-swagger-codegen/action.yml b/.github/actions/setup-swagger-codegen/action.yml new file mode 100644 index 0000000..1ff1efa --- /dev/null +++ b/.github/actions/setup-swagger-codegen/action.yml @@ -0,0 +1,37 @@ +name: 'Setup Swagger Codegen' +description: 'Sets up swagger-codegen and erlang-generator' + +inputs: + codegen-version: + description: 'Codegen (swagger-api/swagger-codegen) version to use.' + required: true + type: string + generator-version: + description: 'Erlang generator (valitydev/swagger-generator-erlang) version to use.' + required: true + type: string + +runs: + using: "composite" + steps: + - name: Check Java + run: java --version + + - name: Download swagger-codegen + run: | + wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${{ inputs.codegen-version }}/swagger-codegen-cli-${{ inputs.codegen-version }}.jar -O /usr/local/lib/swagger-codegen/swagger-codegen-cli.jar + + # - name: Download swagger-generator-erlang + # run: | + # wget someurl -O /usr/local/lib/swagger-codegen/swagger-generator-erlang.jar + + - name: Make swagger-codegen shortcut + run: | + echo "#!/bin/sh" > /usr/local/bin/swagger-codegen + echo "java -cp /usr/local/lib/swagger-codegen/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen \$*" >> /usr/local/bin/swagger-codegen + chmod +x /usr/local/bin/swagger-codegen + + - name: Test codegen + run: | + /usr/local/bin/swagger-codegen version + /usr/local/bin/swagger-codegen langs diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 9862330..8378a30 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -8,6 +8,7 @@ on: required: false default: "" type: string + # Beam env otp-version: description: 'Erlang/OTP version to use.' required: true @@ -16,10 +17,34 @@ on: description: 'Rebar version to use.' required: true type: string + # Thrift options + use-thirft: + description: 'Whether or not to install the thirft compiler.' + required: false + default: false + type: boolean thrift-version: description: 'Thrift (valitydev/thrift) version to use.' - required: true + required: false + default: "0.14.2.1" type: string + # Codegen options + use-swagger-codegen: + description: 'Whether or not to install the swagger code generator.' + required: false + default: false + type: boolean + swagger-codegen-version: + description: 'Codegen (swagger-api/swagger-codegen) version to use.' + required: false + default: "2.4.25" + type: string + erlang-generator-version: + description: 'Erlang generator (valitydev/swagger-generator-erlang) version to use.' + required: false + default: "1.0.0" + type: string + # Test env run-ct-with-compose: description: 'Run tests in a docker-compose environment, requires a docker-compose.yml file (see `valitydev/erlang-templates` for examples).' required: false @@ -40,6 +65,19 @@ jobs: otp-version: ${{ inputs.otp-version }} rebar3-version: ${{ inputs.rebar-version }} + - name: Setup Thrift compiler + if: ${{ inputs.use-thirft }} + uses: valitydev/action-setup-thrift@v0.0.5 + with: + thrift-version: ${{ inputs.thrift-version }} + + - name: Setup Swagger Codegen + if: ${{ inputs.use-swagger-codegen }} + uses: ./.github/actions/setup-swagger-codegen + with: + codegen-version: ${{ inputs.swagger-codegen-version }} + generator-version: ${{ inputs.erlang-generator-version }} + - name: Cache _build uses: actions/cache@v2 with: @@ -49,7 +87,9 @@ jobs: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Compile - run: rebar3 compile + run: | + rebar3 compile + rebar3 as test compile check: name: Check @@ -96,11 +136,6 @@ jobs: otp-version: ${{ inputs.otp-version }} rebar3-version: ${{ inputs.rebar-version }} - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.5 - with: - thrift-version: ${{ inputs.thrift-version }} - - name: Cache _build uses: actions/cache@v2 with: @@ -142,11 +177,6 @@ jobs: restore-keys: | ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - - name: Setup Thrift compiler - uses: valitydev/action-setup-thrift@v0.0.5 - with: - thrift-version: ${{ inputs.thrift-version }} - - name: Run EUnit run: rebar3 eunit --cover From c1429af97ce1c0f96afcd2698821e90402b1bed9 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 26 Jan 2022 14:48:05 +0300 Subject: [PATCH 05/21] fix typo --- .github/workflows/erlang-parallel-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 8378a30..d2e104c 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -18,8 +18,8 @@ on: required: true type: string # Thrift options - use-thirft: - description: 'Whether or not to install the thirft compiler.' + use-thrift: + description: 'Whether or not to install the thrift compiler.' required: false default: false type: boolean @@ -66,7 +66,7 @@ jobs: rebar3-version: ${{ inputs.rebar-version }} - name: Setup Thrift compiler - if: ${{ inputs.use-thirft }} + if: ${{ inputs.use-thrift }} uses: valitydev/action-setup-thrift@v0.0.5 with: thrift-version: ${{ inputs.thrift-version }} From 2c356d7e10f038d942ba9ff597fcb7e332383b75 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 26 Jan 2022 15:33:18 +0300 Subject: [PATCH 06/21] add a way to reset build caches --- .github/workflows/erlang-parallel-build.yml | 26 +++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index d2e104c..e84031b 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -50,6 +50,12 @@ on: required: false default: false type: boolean + # Workflow env + cache-version: + description: 'Cache version. Only change this if you *need* to reset build caches.' + required: false + default: "v1" + type: string jobs: build: @@ -82,9 +88,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Compile run: | @@ -109,9 +115,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Check formatting run: rebar3 fmt -c @@ -140,17 +146,17 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Cache PLTs uses: actions/cache@v2 with: path: _build/test/rebar3_*_plt - key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-plt-${{ hashFiles('rebar.lock') }} + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-plt-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ runner.os }}-otp-${{ inputs.otp-version }}-plt- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-plt- - name: Run dialyzer run: rebar3 as test dialyzer @@ -173,9 +179,9 @@ jobs: uses: actions/cache@v2 with: path: _build/*/lib - key: ${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Run EUnit run: rebar3 eunit --cover From 1562b4ce89ad50500ebe3ba22231b27d9f1a2f07 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 26 Jan 2022 19:50:04 +0300 Subject: [PATCH 07/21] attempt to retrieve cache partially --- .github/workflows/erlang-parallel-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index e84031b..4c6d64a 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -114,7 +114,7 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/*/lib + path: _build/default/lib key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- @@ -145,7 +145,7 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/*/lib + path: _build/test/lib key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- @@ -178,7 +178,7 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/*/lib + path: _build/test/lib key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- From 2bf1aa52c01c64889575d93cb580eb7354170964 Mon Sep 17 00:00:00 2001 From: kehitt Date: Wed, 26 Jan 2022 19:55:29 +0300 Subject: [PATCH 08/21] Revert "attempt to retrieve cache partially" This reverts commit 1562b4ce89ad50500ebe3ba22231b27d9f1a2f07. --- .github/workflows/erlang-parallel-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 4c6d64a..e84031b 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -114,7 +114,7 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/default/lib + path: _build/*/lib key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- @@ -145,7 +145,7 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/test/lib + path: _build/*/lib key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- @@ -178,7 +178,7 @@ jobs: - name: Cache _build uses: actions/cache@v2 with: - path: _build/test/lib + path: _build/*/lib key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- From 1f3ca55ae7028825224bc3c968952477a8b696d8 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 12:09:19 +0300 Subject: [PATCH 09/21] split caches in two --- .github/workflows/erlang-parallel-build.yml | 40 ++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index e84031b..a884dd5 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -84,13 +84,21 @@ jobs: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} - - name: Cache _build + - name: Cache _build/default uses: actions/cache@v2 with: - path: _build/*/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + path: _build/default/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-default-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-default- + + - name: Cache _build/test + uses: actions/cache@v2 + with: + path: _build/test/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test-${{ hashFiles('rebar.lock') }} + restore-keys: | + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test- - name: Compile run: | @@ -111,13 +119,13 @@ jobs: otp-version: ${{ inputs.otp-version }} rebar3-version: ${{ inputs.rebar-version }} - - name: Cache _build + - name: Cache _build/default uses: actions/cache@v2 with: - path: _build/*/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + path: _build/default/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-default-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-default- - name: Check formatting run: rebar3 fmt -c @@ -142,13 +150,13 @@ jobs: otp-version: ${{ inputs.otp-version }} rebar3-version: ${{ inputs.rebar-version }} - - name: Cache _build + - name: Cache _build/test uses: actions/cache@v2 with: - path: _build/*/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + path: _build/test/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test- - name: Cache PLTs uses: actions/cache@v2 @@ -175,13 +183,13 @@ jobs: otp-version: ${{ inputs.otp-version }} rebar3-version: ${{ inputs.rebar-version }} - - name: Cache _build + - name: Cache _build/test uses: actions/cache@v2 with: - path: _build/*/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} + path: _build/test/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test- - name: Run EUnit run: rebar3 eunit --cover From 86839162931266d7f5f1f046a0e96ead1a03f3cf Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 12:17:20 +0300 Subject: [PATCH 10/21] Revert "split caches in two" This reverts commit 1f3ca55ae7028825224bc3c968952477a8b696d8. --- .github/workflows/erlang-parallel-build.yml | 40 +++++++++------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index a884dd5..e84031b 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -84,21 +84,13 @@ jobs: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} - - name: Cache _build/default + - name: Cache _build uses: actions/cache@v2 with: - path: _build/default/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-default-${{ hashFiles('rebar.lock') }} + path: _build/*/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-default- - - - name: Cache _build/test - uses: actions/cache@v2 - with: - path: _build/test/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test-${{ hashFiles('rebar.lock') }} - restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Compile run: | @@ -119,13 +111,13 @@ jobs: otp-version: ${{ inputs.otp-version }} rebar3-version: ${{ inputs.rebar-version }} - - name: Cache _build/default + - name: Cache _build uses: actions/cache@v2 with: - path: _build/default/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-default-${{ hashFiles('rebar.lock') }} + path: _build/*/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-default- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Check formatting run: rebar3 fmt -c @@ -150,13 +142,13 @@ jobs: otp-version: ${{ inputs.otp-version }} rebar3-version: ${{ inputs.rebar-version }} - - name: Cache _build/test + - name: Cache _build uses: actions/cache@v2 with: - path: _build/test/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test-${{ hashFiles('rebar.lock') }} + path: _build/*/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Cache PLTs uses: actions/cache@v2 @@ -183,13 +175,13 @@ jobs: otp-version: ${{ inputs.otp-version }} rebar3-version: ${{ inputs.rebar-version }} - - name: Cache _build/test + - name: Cache _build uses: actions/cache@v2 with: - path: _build/test/lib - key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test-${{ hashFiles('rebar.lock') }} + path: _build/*/lib + key: ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-${{ hashFiles('rebar.lock') }} restore-keys: | - ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build-test- + ${{ inputs.cache-version }}-${{ runner.os }}-otp-${{ inputs.otp-version }}-build- - name: Run EUnit run: rebar3 eunit --cover From 9a7c416d60ec74a83771cd88447438b88be5e324 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 12:24:03 +0300 Subject: [PATCH 11/21] move codegen action to a different repo --- .../actions/setup-swagger-codegen/action.yml | 37 ------------------- .github/workflows/erlang-parallel-build.yml | 2 +- 2 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 .github/actions/setup-swagger-codegen/action.yml diff --git a/.github/actions/setup-swagger-codegen/action.yml b/.github/actions/setup-swagger-codegen/action.yml deleted file mode 100644 index 1ff1efa..0000000 --- a/.github/actions/setup-swagger-codegen/action.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: 'Setup Swagger Codegen' -description: 'Sets up swagger-codegen and erlang-generator' - -inputs: - codegen-version: - description: 'Codegen (swagger-api/swagger-codegen) version to use.' - required: true - type: string - generator-version: - description: 'Erlang generator (valitydev/swagger-generator-erlang) version to use.' - required: true - type: string - -runs: - using: "composite" - steps: - - name: Check Java - run: java --version - - - name: Download swagger-codegen - run: | - wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${{ inputs.codegen-version }}/swagger-codegen-cli-${{ inputs.codegen-version }}.jar -O /usr/local/lib/swagger-codegen/swagger-codegen-cli.jar - - # - name: Download swagger-generator-erlang - # run: | - # wget someurl -O /usr/local/lib/swagger-codegen/swagger-generator-erlang.jar - - - name: Make swagger-codegen shortcut - run: | - echo "#!/bin/sh" > /usr/local/bin/swagger-codegen - echo "java -cp /usr/local/lib/swagger-codegen/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen \$*" >> /usr/local/bin/swagger-codegen - chmod +x /usr/local/bin/swagger-codegen - - - name: Test codegen - run: | - /usr/local/bin/swagger-codegen version - /usr/local/bin/swagger-codegen langs diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index e84031b..176b6fe 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -79,7 +79,7 @@ jobs: - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: ./.github/actions/setup-swagger-codegen + uses: valitydev/action-setup-swagger-codegen@c442b47daa70bdf6688b373ce4d45d80627023de with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} From 882ffb229d6ac997f4dfdd41e1f7612190818050 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 12:28:32 +0300 Subject: [PATCH 12/21] update action --- .github/workflows/erlang-parallel-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 176b6fe..b1b0ee1 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -77,9 +77,10 @@ jobs: with: thrift-version: ${{ inputs.thrift-version }} + # NOTICE: This action is WIP - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: valitydev/action-setup-swagger-codegen@c442b47daa70bdf6688b373ce4d45d80627023de + uses: valitydev/action-setup-swagger-codegen@d08e870c37f680ba657762075d59257aeb3738f2 with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} From ea4d852d3f827b0851cbecea6e2ecf1bf6272f17 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 12:33:57 +0300 Subject: [PATCH 13/21] update codegen action --- .github/workflows/erlang-parallel-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index b1b0ee1..863939d 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -80,7 +80,7 @@ jobs: # NOTICE: This action is WIP - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: valitydev/action-setup-swagger-codegen@d08e870c37f680ba657762075d59257aeb3738f2 + uses: valitydev/action-setup-swagger-codegen@a4920c1 with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} From 883a670e609ea40b903caf7f1fb9642aaec46eeb Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 12:35:50 +0300 Subject: [PATCH 14/21] unshorten codegen action ref --- .github/workflows/erlang-parallel-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 863939d..334e66a 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -80,7 +80,7 @@ jobs: # NOTICE: This action is WIP - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: valitydev/action-setup-swagger-codegen@a4920c1 + uses: valitydev/action-setup-swagger-codegen@a4920c1d3b0a48a865fcc4d7920c2a9305f8e68a with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} From 1d885a8fbfd63e15f05bc4c62421da9a994d633d Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 12:50:28 +0300 Subject: [PATCH 15/21] update codegen action --- .github/workflows/erlang-parallel-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 334e66a..1a69da6 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -80,7 +80,7 @@ jobs: # NOTICE: This action is WIP - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: valitydev/action-setup-swagger-codegen@a4920c1d3b0a48a865fcc4d7920c2a9305f8e68a + uses: valitydev/action-setup-swagger-codegen@607f5e98870abfcf2562a0cb437734a17655265f with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} From 1702e31a020a82cb0a37326cea1ccae3e7ede006 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 14:43:32 +0300 Subject: [PATCH 16/21] replace service-name with run-ct-compose-container-name --- .github/workflows/erlang-parallel-build.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 1a69da6..e2f6b19 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -3,11 +3,6 @@ name: Erlang Parallel Build on: workflow_call: inputs: - service-name: - description: 'Service name, as in docker-compose.yml (only required when running when run-ct-with-compose: true).' - required: false - default: "" - type: string # Beam env otp-version: description: 'Erlang/OTP version to use.' @@ -50,6 +45,11 @@ on: required: false default: false type: boolean + run-ct-compose-container-name: + description: 'Service name, as in docker-compose.yml (default: testrunner).' + required: false + default: "testrunner" + type: string # Workflow env cache-version: description: 'Cache version. Only change this if you *need* to reset build caches.' @@ -197,15 +197,14 @@ jobs: if: ${{ inputs.run-ct-with-compose == true }} env: # Pass workflow params to use in docker-compose.yml - DEV_IMAGE_TAG: ${{ inputs.service-name }}-dev + DEV_IMAGE_TAG: ${{ inputs.run-ct-compose-container-name }}-dev OTP_VERSION: ${{ inputs.otp-version }} THRIFT_VERSION: ${{ inputs.thrift-version }} # Enable buildkit extensions in docker compose COMPOSE_DOCKER_CLI_BUILD: true DOCKER_BUILDKIT: true run: | - [[ "${{ inputs.service-name }}" == "" ]] && exit 1 - docker-compose run --use-aliases --rm ${{ inputs.service-name }} rebar3 ct --cover + docker-compose run --use-aliases --rm ${{ inputs.run-ct-compose-container-name }} rebar3 ct --cover - name: Store CT Logs if: ${{ failure() && (steps.run-ct.outcome == 'failure' || steps.run-ct-w-compose.outcome == 'failure') }} From e8fc248b320c0306f548735658214a5cd7f03f35 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 18:57:33 +0300 Subject: [PATCH 17/21] update codegen action --- .github/workflows/erlang-parallel-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index e2f6b19..aa34793 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -80,7 +80,7 @@ jobs: # NOTICE: This action is WIP - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: valitydev/action-setup-swagger-codegen@607f5e98870abfcf2562a0cb437734a17655265f + uses: valitydev/action-setup-swagger-codegen@57ff8ef874fbd6e2f1e481ab61969d6c170f3283 with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} From daec685d970c04fa60731014e916fbe0ae97a5a9 Mon Sep 17 00:00:00 2001 From: kehitt Date: Thu, 27 Jan 2022 18:59:47 +0300 Subject: [PATCH 18/21] update default generator version --- .github/workflows/erlang-parallel-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index aa34793..24564a7 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -37,7 +37,7 @@ on: erlang-generator-version: description: 'Erlang generator (valitydev/swagger-generator-erlang) version to use.' required: false - default: "1.0.0" + default: "1.0.1" type: string # Test env run-ct-with-compose: From fbf64b39d2f26c87289e10722bbd6a1eb73907ce Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 28 Jan 2022 16:25:29 +0300 Subject: [PATCH 19/21] bump codegen action --- .github/workflows/erlang-parallel-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 24564a7..1288281 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -80,7 +80,7 @@ jobs: # NOTICE: This action is WIP - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: valitydev/action-setup-swagger-codegen@57ff8ef874fbd6e2f1e481ab61969d6c170f3283 + uses: valitydev/action-setup-swagger-codegen@0d53499816c42c7d5acd777f59fc73e304094b26 with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} From 8aeaca5881e031a75f2ab2ad853ce49e4ca33164 Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 28 Jan 2022 16:50:51 +0300 Subject: [PATCH 20/21] pin swagger-codegen action to a tag --- .github/workflows/erlang-parallel-build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 1288281..7d52bf6 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -77,10 +77,9 @@ jobs: with: thrift-version: ${{ inputs.thrift-version }} - # NOTICE: This action is WIP - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: valitydev/action-setup-swagger-codegen@0d53499816c42c7d5acd777f59fc73e304094b26 + uses: valitydev/action-setup-swagger-codegen@0v0.0.1 with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }} From 8f4d2fc5798ed55f73bbe0c70df354e28fb80b65 Mon Sep 17 00:00:00 2001 From: kehitt Date: Fri, 28 Jan 2022 16:51:15 +0300 Subject: [PATCH 21/21] fix typo --- .github/workflows/erlang-parallel-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-parallel-build.yml b/.github/workflows/erlang-parallel-build.yml index 7d52bf6..0d673ef 100644 --- a/.github/workflows/erlang-parallel-build.yml +++ b/.github/workflows/erlang-parallel-build.yml @@ -79,7 +79,7 @@ jobs: - name: Setup Swagger Codegen if: ${{ inputs.use-swagger-codegen }} - uses: valitydev/action-setup-swagger-codegen@0v0.0.1 + uses: valitydev/action-setup-swagger-codegen@v0.0.1 with: codegen-version: ${{ inputs.swagger-codegen-version }} generator-version: ${{ inputs.erlang-generator-version }}