2020-09-07 20:14:10 +08:00
|
|
|
#@ load("@ytt:data", "data")
|
2020-10-06 20:21:33 +08:00
|
|
|
#@ load("@ytt:assert", "assert")
|
2020-12-11 17:28:17 +08:00
|
|
|
#@ load("util.star", "is_unique", "to_build_args")
|
2020-11-18 17:19:12 +08:00
|
|
|
#@ load("helpers.star", "ci_image_tag", "ci_dep_image", "skip_ci_condition")
|
2020-09-07 20:14:10 +08:00
|
|
|
|
2020-11-23 18:32:03 +08:00
|
|
|
#@ def checks_job(dep, erlang_version=None):
|
2020-09-07 20:14:10 +08:00
|
|
|
name: #@ dep.name + "-checks"
|
|
|
|
needs: [prepare]
|
|
|
|
runs-on: ubuntu-18.04
|
2020-11-18 17:19:12 +08:00
|
|
|
if: #@ skip_ci_condition()
|
2020-09-07 20:14:10 +08:00
|
|
|
outputs:
|
|
|
|
step_start: ${{ steps.buildevents.outputs.step_start }}
|
|
|
|
#@yaml/text-templated-strings
|
|
|
|
steps:
|
|
|
|
- name: RECORD STEP START
|
|
|
|
id: buildevents
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=step_start::$(date +%s)"
|
|
|
|
- name: CHECKOUT REPOSITORY
|
|
|
|
uses: actions/checkout@v2
|
2020-10-06 20:21:33 +08:00
|
|
|
- name: VALIDATE KNOWN CT SUITES
|
|
|
|
env:
|
|
|
|
project: #@ dep.name
|
|
|
|
#@ suite_names = [suite.name for suite in dep.suites]
|
|
|
|
#@ None if is_unique(suite_names) else assert.fail('{} suite names are not unique'.format(dep.name))
|
|
|
|
run: |
|
|
|
|
ci/scripts/validate-workflow.sh (@= " ".join(suite_names) @)
|
2020-12-12 18:10:57 +08:00
|
|
|
- name: FETCH ci DOCKER IMAGE CACHE
|
2020-12-09 18:55:37 +08:00
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
2020-12-12 18:10:57 +08:00
|
|
|
key: #@ ci_image_tag(erlang_version)
|
|
|
|
path: ci.tar
|
|
|
|
- name: LOAD ci DOCKER IMAGE FROM CACHE
|
|
|
|
run: |
|
|
|
|
docker load --input ci.tar
|
2020-12-09 18:55:37 +08:00
|
|
|
- name: RUN CHECKS
|
2020-12-12 18:10:57 +08:00
|
|
|
run: |
|
|
|
|
docker build . \
|
|
|
|
--file ci/dockerfiles/ci-dep \
|
|
|
|
--build-arg IMAGE_TAG=(@= ci_image_tag(erlang_version) @) \
|
|
|
|
--build-arg BUILDEVENT_APIKEY=${{ secrets.HONEYCOMB_API_KEY }} \
|
|
|
|
--build-arg project=(@= dep.name @) \
|
|
|
|
--tag eu.gcr.io/cf-rabbitmq-core/ci-(@= dep.name @):(@= ci_image_tag(erlang_version) @)
|
|
|
|
- name: FETCH ci-(@= dep.name @) DOCKER IMAGE CACHE
|
|
|
|
uses: actions/cache@v2
|
2020-12-11 20:39:56 +08:00
|
|
|
with:
|
2020-12-12 18:10:57 +08:00
|
|
|
key: #@ ci_image_tag(erlang_version) + "+" + dep.name
|
2020-12-11 20:39:56 +08:00
|
|
|
path: ci-(@= dep.name @).tar
|
2020-12-11 23:06:50 +08:00
|
|
|
- name: SAVE CI DOCKER IMAGE IN CACHE
|
|
|
|
run: |
|
|
|
|
docker save --output ci-(@= dep.name @).tar (@= ci_dep_image(erlang_version, dep.name) @)
|
2020-09-07 20:14:10 +08:00
|
|
|
#@ end
|
|
|
|
|
2020-12-11 17:28:17 +08:00
|
|
|
#@ def ct_suites_job(dep, suite_name, erlang_version=None):
|
|
|
|
name: #@ dep.name + "-ct-" + suite_name
|
2020-09-07 20:14:10 +08:00
|
|
|
needs:
|
|
|
|
- prepare
|
|
|
|
- #@ dep.name + "-checks"
|
|
|
|
runs-on: ubuntu-18.04
|
2020-11-18 17:19:12 +08:00
|
|
|
if: #@ skip_ci_condition()
|
2020-09-07 20:14:10 +08:00
|
|
|
#@yaml/text-templated-strings
|
|
|
|
steps:
|
2020-12-11 23:06:50 +08:00
|
|
|
- uses: actions/cache@v2
|
2020-09-07 20:14:10 +08:00
|
|
|
with:
|
2020-12-12 18:10:57 +08:00
|
|
|
key: #@ ci_image_tag(erlang_version) + "+" + dep.name
|
2020-12-11 23:06:50 +08:00
|
|
|
path: ci-(@= dep.name @).tar
|
|
|
|
- name: LOAD CI DOCKER IMAGE FROM CACHE
|
2020-09-07 20:14:10 +08:00
|
|
|
run: |
|
2020-12-11 20:05:35 +08:00
|
|
|
docker load --input ci-(@= dep.name @).tar
|
2020-12-11 17:28:17 +08:00
|
|
|
- name: #@ "RUN ct-" + suite_name
|
|
|
|
id: tests
|
2020-09-07 20:14:10 +08:00
|
|
|
run: |
|
2020-12-11 17:28:17 +08:00
|
|
|
mkdir ct-(@= suite_name @)-logs && chmod 777 ct-(@= suite_name @)-logs
|
2020-09-07 20:14:10 +08:00
|
|
|
docker run \
|
|
|
|
--env project=(@= dep.name @) \
|
2020-12-11 17:28:17 +08:00
|
|
|
--env CT_SUITE=(@= suite_name @) \
|
2020-09-07 20:14:10 +08:00
|
|
|
--env GITHUB_RUN_ID=${{ github.run_id }} \
|
|
|
|
--env BUILDEVENT_APIKEY=${{ secrets.HONEYCOMB_API_KEY }} \
|
2020-12-11 17:28:17 +08:00
|
|
|
--volume ${PWD}/ct-(@= suite_name @)-logs:/workspace/ct-logs \
|
2020-11-23 18:32:03 +08:00
|
|
|
(@= ci_dep_image(erlang_version, dep.name) @) \
|
2020-09-07 20:14:10 +08:00
|
|
|
/workspace/rabbitmq/ci/scripts/ct-suite.sh
|
|
|
|
- name: ON FAILURE UPLOAD TESTS LOGS ARTIFACT
|
|
|
|
#! https://github.com/marketplace/actions/upload-artifact
|
|
|
|
uses: actions/upload-artifact@v2-preview
|
2020-12-11 17:28:17 +08:00
|
|
|
if: failure() && steps.tests.outcome == 'failure'
|
2020-09-07 20:14:10 +08:00
|
|
|
with:
|
2020-12-11 17:28:17 +08:00
|
|
|
name: (@= dep.name @)-ct-(@= suite_name @)-logs
|
|
|
|
path: "ct-(@= suite_name @)-logs/*-ct-logs-*.tar.xz"
|
2020-11-23 18:32:03 +08:00
|
|
|
#@ if erlang_version == data.values.erlang_versions[0]:
|
2020-11-10 19:55:14 +08:00
|
|
|
#@ for version in data.values.secondary_umbrella_gitrefs:
|
2020-12-11 17:28:17 +08:00
|
|
|
#@ logs_dir = 'ct-{}-logs-{}'.format(suite_name, version)
|
|
|
|
#@ step_id = "tests-{}".format(version.replace(".","_"))
|
|
|
|
- name: #@ "RUN ct-{} [mixed {}]".format(suite_name, version)
|
|
|
|
id: #@ step_id
|
2020-11-10 19:55:14 +08:00
|
|
|
run: |
|
|
|
|
mkdir (@= logs_dir @) && chmod 777 (@= logs_dir @)
|
|
|
|
docker run \
|
|
|
|
--env project=(@= dep.name @) \
|
2020-12-11 17:28:17 +08:00
|
|
|
--env CT_SUITE=(@= suite_name @) \
|
2020-11-10 19:55:14 +08:00
|
|
|
--env GITHUB_RUN_ID=${{ github.run_id }} \
|
|
|
|
--env BUILDEVENT_APIKEY=${{ secrets.HONEYCOMB_API_KEY }} \
|
|
|
|
--env SECONDARY_UMBRELLA_VERSION=(@= version @) \
|
|
|
|
--volume ${PWD}/(@= logs_dir @):/workspace/ct-logs \
|
2020-11-23 18:32:03 +08:00
|
|
|
(@= ci_dep_image(erlang_version, dep.name) @) \
|
2020-11-10 19:55:14 +08:00
|
|
|
/workspace/rabbitmq/ci/scripts/ct-suite.sh
|
|
|
|
- name: #@ 'ON FAILURE UPLOAD TESTS LOGS ARTIFACT [mixed {}]'.format(version)
|
|
|
|
#! https://github.com/marketplace/actions/upload-artifact
|
|
|
|
uses: actions/upload-artifact@v2-preview
|
|
|
|
#! For whatever reason, "if: steps.(@= suite @).outcome == 'failure'" never executes,
|
|
|
|
#! so just run always
|
2020-12-11 17:28:17 +08:00
|
|
|
if: failure() && steps.(@= step_id @).outcome == 'failure'
|
2020-11-10 19:55:14 +08:00
|
|
|
with:
|
2020-12-11 17:28:17 +08:00
|
|
|
name: (@= dep.name @)-ct-(@= suite_name @)-logs-mixed-(@= version @)
|
2020-11-10 19:55:14 +08:00
|
|
|
path: "(@= logs_dir @)/*-ct-logs-*.tar.xz"
|
|
|
|
#@ end
|
2020-09-07 20:14:10 +08:00
|
|
|
#@ end
|
|
|
|
#@ end
|
|
|
|
|
2020-11-23 18:32:03 +08:00
|
|
|
#@ def collect_job(dep, erlang_version=None):
|
2020-09-07 20:14:10 +08:00
|
|
|
name: #@ dep.name
|
2020-12-11 17:28:17 +08:00
|
|
|
needs: #@ [dep.name + "-checks"] + [dep.name + "-ct-" + suite.name for suite in dep.suites]
|
2020-09-07 20:14:10 +08:00
|
|
|
runs-on: ubuntu-18.04
|
2020-11-19 20:49:03 +08:00
|
|
|
#! See https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#job-status-check-functions
|
2020-11-27 16:48:05 +08:00
|
|
|
#! as to why '(success() || failure())' is needed
|
|
|
|
if: #@ skip_ci_condition() + " && (success() || failure())"
|
2020-09-07 20:14:10 +08:00
|
|
|
#@yaml/text-templated-strings
|
|
|
|
steps:
|
2020-12-11 23:06:50 +08:00
|
|
|
- uses: actions/cache@v2
|
2020-09-07 20:14:10 +08:00
|
|
|
with:
|
2020-12-12 18:10:57 +08:00
|
|
|
key: #@ ci_image_tag(erlang_version) + "+" + dep.name
|
2020-12-11 23:06:50 +08:00
|
|
|
path: ci-(@= dep.name @).tar
|
|
|
|
- name: LOAD CI DOCKER IMAGE FROM CACHE
|
2020-12-11 19:42:49 +08:00
|
|
|
run: |
|
2020-12-11 20:05:35 +08:00
|
|
|
docker load --input ci-(@= dep.name @).tar
|
2020-09-07 20:14:10 +08:00
|
|
|
- name: RECORD STEP FINISH
|
|
|
|
run: |
|
|
|
|
docker run \
|
|
|
|
--env project=(@= dep.name @) \
|
|
|
|
--env GITHUB_RUN_ID=${{ github.run_id }} \
|
|
|
|
--env BUILDEVENT_APIKEY=${{ secrets.HONEYCOMB_API_KEY }} \
|
|
|
|
--env STEP_START=${{ needs.(@= dep.name @)-checks.outputs.step_start }} \
|
2020-11-23 18:32:03 +08:00
|
|
|
(@= ci_dep_image(erlang_version, dep.name) @) \
|
2020-09-07 20:14:10 +08:00
|
|
|
/workspace/rabbitmq/ci/scripts/collect.sh
|
|
|
|
#@ end
|