You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ra...@apache.org on 2022/03/24 15:15:32 UTC
[trafficcontrol] branch master updated: GitHub Actions ATS RPM: Verify that the cached or built RPM matches the expected RPM name (#6689)
This is an automated email from the ASF dual-hosted git repository.
rawlin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new d4286d8 GitHub Actions ATS RPM: Verify that the cached or built RPM matches the expected RPM name (#6689)
d4286d8 is described below
commit d4286d867db2a094c39e127336869ad8cc0eb74f
Author: Zach Hoffman <zr...@apache.org>
AuthorDate: Thu Mar 24 09:15:14 2022 -0600
GitHub Actions ATS RPM: Verify that the cached or built RPM matches the expected RPM name (#6689)
* Rename fetch-github-branch-sha action to repo-info
* Cache ATS RPM by expected RPM name
* Verify that the cached or built RPM matches the expected RPM name
* git describe -> git describe --tags to include unannotated tags
---
.../README.md | 8 ++++----
.../action.yml | 11 ++++-------
.../entrypoint.sh | 23 +++++++++++++++++++---
.github/workflows/cache-config-tests.yml | 20 ++++++++++++-------
.github/workflows/ciab.yaml | 21 +++++++++++---------
.github/workflows/health-client-tests.yml | 20 ++++++++++++-------
.../docker/trafficserver/trafficserver.spec | 6 +++---
traffic_server/_tsb/trafficserver.spec | 6 +++---
8 files changed, 72 insertions(+), 43 deletions(-)
diff --git a/.github/actions/fetch-github-branch-sha/README.md b/.github/actions/repo-info/README.md
similarity index 86%
rename from .github/actions/fetch-github-branch-sha/README.md
rename to .github/actions/repo-info/README.md
index 846f034..6d1c42a 100644
--- a/.github/actions/fetch-github-branch-sha/README.md
+++ b/.github/actions/repo-info/README.md
@@ -17,8 +17,8 @@
under the License.
-->
-# fetch-github-branch-sha docker action
-This action queries for the latest git commit sha and latest tag on a GitHub repo branch.
+# repo-info docker action
+This action builds an RPM name, after fetching the latest git commit sha and latest tag on a GitHub repo branch.
## Inputs
@@ -51,8 +51,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
- - name: Fetch GitHub commit
- uses: ./.github/actions/fetch-github-branch-sha
+ - name: Fetch RPM name
+ uses: ./.github/actions/repo-info
with:
- owner: apache
- repo: trafficserver
diff --git a/.github/actions/fetch-github-branch-sha/action.yml b/.github/actions/repo-info/action.yml
similarity index 84%
rename from .github/actions/fetch-github-branch-sha/action.yml
rename to .github/actions/repo-info/action.yml
index a3f3efd..54cd873 100644
--- a/.github/actions/fetch-github-branch-sha/action.yml
+++ b/.github/actions/repo-info/action.yml
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-name: 'fetch-github-branch-sha'
+name: 'repo-info'
description: 'Fetches the most recent commit from a github repository branch'
inputs:
owner:
@@ -28,12 +28,9 @@ inputs:
description: 'The repository branch to query ie, "8.1.0-branch"'
required: true
outputs:
- sha:
- description: 'The latest git commit sha on the given branch'
- value: ${{ steps.entrypoint.outputs.sha }}
- latest-tag:
- description: 'The latest git tag on the given branch'
- value: ${{ steps.entrypoint.outputs.latest-tag }}
+ expected-rpm-name:
+ description: 'The name that an RPM with the fetched git tag and commit sha is expected to have'
+ value: ${{ steps.entrypoint.outputs.expected-rpm-name }}
runs:
using: 'composite'
steps:
diff --git a/.github/actions/fetch-github-branch-sha/entrypoint.sh b/.github/actions/repo-info/entrypoint.sh
similarity index 72%
rename from .github/actions/fetch-github-branch-sha/entrypoint.sh
rename to .github/actions/repo-info/entrypoint.sh
index 54c5c10..36e02b7 100755
--- a/.github/actions/fetch-github-branch-sha/entrypoint.sh
+++ b/.github/actions/repo-info/entrypoint.sh
@@ -32,8 +32,15 @@ if ! _brinfo="$(curl --silent "${GITHUB_API_URL}/repos/${INPUT_OWNER}/${INPUT_RE
exit 2
fi
+if [[ "$RHEL_VERSION" -ge 8 ]]; then
+ sha_length=9
+else
+ sha_length=7
+fi
+
# parse out the commit sha
_sha="$(<<<"$_brinfo" jq -r .commit.sha)"
+_sha="${_sha::${sha_length}}"
# verify the sha
if [[ -z "${_sha}" || "${_sha}" == "null" ]]; then
@@ -41,8 +48,6 @@ if [[ -z "${_sha}" || "${_sha}" == "null" ]]; then
exit 3
fi
-echo "::set-output name=sha::${_sha}"
-
branch_prefix_pattern="^$(<<<"$INPUT_BRANCH" grep -o '.*\.' | sed 's/\./\\./g')[0-9.]+$"
if ! tags_info="$(curl --silent "${GITHUB_API_URL}/repos/${INPUT_OWNER}/${INPUT_REPO}/tags")"; then
@@ -53,6 +58,18 @@ fi
latest_tag="$(<<<"$tags_info" jq -r --arg BRANCH_PREFIX_PATTERN "$branch_prefix_pattern" '.[] | .name | select(test($BRANCH_PREFIX_PATTERN))' |
head -n1)"
-echo "::set-output name=latest-tag::${latest_tag}"
+commit_range="${latest_tag}...${INPUT_BRANCH}"
+if ! compare="$(curl --silent "${GITHUB_API_URL}/repos/${INPUT_OWNER}/${INPUT_REPO}/compare/${commit_range}")"; then
+ echo "Error: failed to fetch comparison info for commit range ${commit_range}"
+ exit 2
+fi
+ahead_by="$(<<<"$compare" jq -r .ahead_by)"
+
+if [[ -z "$ahead_by" ]]; then
+ echo "Error: could not fetch commit count between tag ${latest_tag} and the tip of branch ${INPUT_BRANCH}"
+fi
+expected_rpm_name="${INPUT_REPO}-${latest_tag}-${ahead_by}.${_sha}.el${RHEL_VERSION}.${TARGET_ARCH}.rpm"
+
+echo "::set-output name=expected-rpm-name::${expected_rpm_name}"
exit 0
diff --git a/.github/workflows/cache-config-tests.yml b/.github/workflows/cache-config-tests.yml
index 5c31bfd..1b0251b 100644
--- a/.github/workflows/cache-config-tests.yml
+++ b/.github/workflows/cache-config-tests.yml
@@ -18,8 +18,9 @@
name: Traffic Control Cache Config integration tests
env:
- RHEL_VERSION: 8
ATS_VERSION: 8.1.x
+ RHEL_VERSION: 8
+ TARGET_ARCH: x86_64
on:
workflow_dispatch:
@@ -39,7 +40,7 @@ on:
- vendor/**.go
- vendor/modules.txt
- .github/actions/build-ats-test-rpm/**
- - .github/actions/fetch-github-branch-sha/**
+ - .github/actions/repo-info/**
- .github/actions/cache-config-integration-tests/**
create:
pull_request:
@@ -58,7 +59,7 @@ on:
- vendor/**.go
- vendor/modules.txt
- .github/actions/build-ats-test-rpm/**
- - .github/actions/fetch-github-branch-sha/**
+ - .github/actions/repo-info/**
- .github/actions/cache-config-integration-tests/**
types: [opened, reopened, ready_for_review, synchronize]
@@ -106,24 +107,29 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- - name: Get latest commit sha and latest tag
- uses: ./.github/actions/fetch-github-branch-sha
+ - name: Get expected RPM name
+ uses: ./.github/actions/repo-info
with:
owner: apache
repo: trafficserver
branch: ${{ env.ATS_VERSION }}
- id: git-repo-sha
+ id: repo-info
- name: Check Cache
id: ats-rpm-cache
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/dist
- key: ${{ steps.git-repo-sha.outputs.sha }}-${{ steps.git-repo-sha.outputs.latest-tag }}-el${{ env.RHEL_VERSION }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
+ key: ${{ steps.repo-info.outputs.expected-rpm-name }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
- name: Build ATS RPM
if: steps.ats-rpm-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/build-ats-test-rpm
env:
ATC_COMPONENT: ${{ github.job }}
+ - name: Check ATS RPM name
+ run: |
+ set -o errexit -o nounset -o xtrace
+ actual_rpm_name="$(ls dist | grep -E '^trafficserver-[0-9.]+-[0-9]+\.[0-9a-f]+.el${{ env.RHEL_VERSION }}.${{ env.TARGET_ARCH }}.rpm$')"
+ [[ "${{ steps.repo-info.outputs.expected-rpm-name }}" == "$actual_rpm_name" ]]
- name: Upload RPM
uses: actions/upload-artifact@v2
with:
diff --git a/.github/workflows/ciab.yaml b/.github/workflows/ciab.yaml
index 659f4e3..f2de50d 100644
--- a/.github/workflows/ciab.yaml
+++ b/.github/workflows/ciab.yaml
@@ -19,6 +19,7 @@ name: CDN-in-a-Box CI
env:
RHEL_VERSION: 8
+ TARGET_ARCH: x86_64
# alpine:3.13
ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
@@ -37,7 +38,7 @@ on:
- '.github/**'
- '!.github/actions/build-ciab/**'
- '!.github/actions/build-rpms/**'
- - '!.github/actions/fetch-github-branch-sha/**'
+ - '!.github/actions/repo-info/**'
- '!.github/actions/run-ciab/**'
- '!infrastructure/cdn-in-a-box/optional/**'
- '!.github/workflows/ciab.yaml'
@@ -67,7 +68,7 @@ on:
- '.github/**'
- '!.github/actions/build-ciab/**'
- '!.github/actions/build-rpms/**'
- - '!.github/actions/fetch-github-branch-sha/**'
+ - '!.github/actions/repo-info/**'
- '!.github/actions/run-ciab/**'
- '!infrastructure/cdn-in-a-box/optional/**'
- '!.github/workflows/ciab.yaml'
@@ -249,27 +250,29 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- - name: Get latest commit sha and latest tag
- uses: ./.github/actions/fetch-github-branch-sha
+ - name: Get expected RPM name
+ uses: ./.github/actions/repo-info
with:
owner: apache
repo: trafficserver
branch: 8.1.x
- id: git-repo-sha
+ id: repo-info
- name: Check Cache
id: ats-rpm-cache
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/dist
- key: ${{ steps.git-repo-sha.outputs.sha }}-${{ steps.git-repo-sha.outputs.latest-tag }}-el${{ env.RHEL_VERSION }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
+ key: ${{ steps.repo-info.outputs.expected-rpm-name }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
- name: Build ATS RPM
if: steps.ats-rpm-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/build-ats-test-rpm
env:
ATC_COMPONENT: ${{ github.job }}
- - name: Display structure of dist directory
- run: ls -lR
- working-directory: ${{ github.workspace }}/dist
+ - name: Check ATS RPM name
+ run: |
+ set -o errexit -o nounset -o xtrace
+ actual_rpm_name="$(ls dist | grep -E '^trafficserver-[0-9.]+-[0-9]+\.[0-9a-f]+.el${{ env.RHEL_VERSION }}.${{ env.TARGET_ARCH }}.rpm$')"
+ [[ "${{ steps.repo-info.outputs.expected-rpm-name }}" == "$actual_rpm_name" ]]
- name: Upload RPM
uses: actions/upload-artifact@v2
with:
diff --git a/.github/workflows/health-client-tests.yml b/.github/workflows/health-client-tests.yml
index 850583e..08e2857 100644
--- a/.github/workflows/health-client-tests.yml
+++ b/.github/workflows/health-client-tests.yml
@@ -18,8 +18,9 @@
name: Traffic Control Health Client integration tests
env:
- RHEL_VERSION: 8
ATS_VERSION: 8.1.x
+ RHEL_VERSION: 8
+ TARGET_ARCH: x86_64
on:
workflow_dispatch:
@@ -39,7 +40,7 @@ on:
- vendor/**.go
- vendor/modules.txt
- .github/actions/build-ats-test-rpm/**
- - .github/actions/fetch-github-branch-sha/**
+ - .github/actions/repo-info/**
- .github/actions/health-client-integration-tests/**
create:
pull_request:
@@ -58,7 +59,7 @@ on:
- vendor/**.go
- vendor/modules.txt
- .github/actions/build-ats-test-rpm/**
- - .github/actions/fetch-github-branch-sha/**
+ - .github/actions/repo-info/**
- .github/actions/health-client-integration-tests/**
types: [opened, reopened, ready_for_review, synchronize]
@@ -107,24 +108,29 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- - name: Get latest commit sha and latest tag
- uses: ./.github/actions/fetch-github-branch-sha
+ - name: Get expected RPM name
+ uses: ./.github/actions/repo-info
with:
owner: apache
repo: trafficserver
branch: ${{ env.ATS_VERSION }}
- id: git-repo-sha
+ id: repo-info
- name: Check Cache
id: ats-rpm-cache
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/dist
- key: ${{ steps.git-repo-sha.outputs.sha }}-${{ steps.git-repo-sha.outputs.latest-tag }}-el${{ env.RHEL_VERSION }}-${{ hashFiles('tc-health-client/testing/docker/trafficserver/**') }}
+ key: ${{ steps.repo-info.outputs.expected-rpm-name }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
- name: Build ATS RPM
if: steps.ats-rpm-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/build-ats-test-rpm
env:
ATC_COMPONENT: ${{ github.job }}
+ - name: Check ATS RPM name
+ run: |
+ set -o errexit -o nounset -o xtrace
+ actual_rpm_name="$(ls dist | grep -E '^trafficserver-[0-9.]+-[0-9]+\.[0-9a-f]+.el${{ env.RHEL_VERSION }}.${{ env.TARGET_ARCH }}.rpm$')"
+ [[ "${{ steps.repo-info.outputs.expected-rpm-name }}" == "$actual_rpm_name" ]]
- name: Upload RPM
uses: actions/upload-artifact@v2
with:
diff --git a/cache-config/testing/docker/trafficserver/trafficserver.spec b/cache-config/testing/docker/trafficserver/trafficserver.spec
index 34076bc..bdaa59b 100644
--- a/cache-config/testing/docker/trafficserver/trafficserver.spec
+++ b/cache-config/testing/docker/trafficserver/trafficserver.spec
@@ -20,9 +20,9 @@
%global src %{_topdir}/SOURCES/trafficserver
%global git_args --git-dir="%{src}/.git" --work-tree="%{src}"
-%global tag %(git %{git_args} describe --long --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\1/' | sed 's/-/_/')
-%global distance %(git %{git_args} describe --long --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\2/')
-%global commit %(git %{git_args} describe --long --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\3/')
+%global tag %(git %{git_args} describe --long --tags --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\1/' | sed 's/-/_/')
+%global distance %(git %{git_args} describe --long --tags --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\2/')
+%global commit %(git %{git_args} describe --long --tags --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\3/')
%global git_serial %(git %{git_args} rev-list HEAD | wc -l)
%global install_prefix "/opt"
%global api_stats "4096"
diff --git a/traffic_server/_tsb/trafficserver.spec b/traffic_server/_tsb/trafficserver.spec
index 59cd25d..9d27aba 100644
--- a/traffic_server/_tsb/trafficserver.spec
+++ b/traffic_server/_tsb/trafficserver.spec
@@ -20,9 +20,9 @@
%global src %{_topdir}/SOURCES/src
%global git_args --git-dir="%{src}/.git" --work-tree="%{src}"
-%global tag %(git %{git_args} describe --long --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\1/' | sed 's/-/_/')
-%global distance %(git %{git_args} describe --long --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\2/')
-%global commit %(git %{git_args} describe --long --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\3/')
+%global tag %(git %{git_args} describe --long --tags --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\1/' | sed 's/-/_/')
+%global distance %(git %{git_args} describe --long --tags --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\2/')
+%global commit %(git %{git_args} describe --long --tags --match='*[0-9.][0-9.][0-9.]' | sed 's/^\\\(.*\\\)-\\\([0-9]\\\+\\\)-g\\\([0-9a-f]\\\+\\\)$/\\\3/')
%global git_serial %(git %{git_args} rev-list HEAD | wc -l)
%global install_prefix "/opt"
%global api_stats "4096"