Create 0fed07831f353316eb85439364d5f2071e33db4f3cbcb4e842269803544553… #632
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
# Trigger on open, synchronize or reopen PR activity against the default base branch | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
Validate-Metadata: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout both this pull request and the master branch | |
- name: Checkout pull request | |
uses: actions/[email protected] | |
with: | |
path: pull-request | |
- name: Checkout base branch | |
uses: actions/checkout@v2 | |
with: | |
ref: master | |
path: master | |
- name: Validate | |
run: | | |
# shellcheck disable=SC2016 | |
# Debug: | |
# env | |
# cat "${GITHUB_EVENT_PATH}" | jq . | |
export BASE="master" | |
export LOCATION="registry" | |
pushd pull-request | |
echo "Fetching base branch '${BASE}':" | |
git fetch origin ${BASE} --depth=1 | |
echo | |
echo "Obtaining PR file change diff:" | |
echo | |
git --no-pager diff --name-status origin/"${BASE}" "${GITHUB_SHA}" > "${GITHUB_SHA}.diff" | |
cat "${GITHUB_SHA}.diff" | |
echo | |
rm -f fail-location fail-filename || : | |
echo "Validating all changed PR files are in the ${LOCATION} directory:" | |
echo | |
awk '{print $2}' "${GITHUB_SHA}.diff" | sort \ | |
| xargs -I{} bash -c '[[ {} =~ ^${LOCATION}/.*$ ]] && echo "pass: {}" || { echo "FAIL: {}"; touch fail-location; }' | |
echo | |
[ -f "fail-location" ] && echo "ABORTING: File change location validation failed" | |
[ -f "fail-filename" ] && echo "ABORTING: File name validation failed" | |
[ -f "fail-location" ] || [ -f "fail-filename" ] && exit 1 | |
popd | |
echo "Obtaining the latest metadata GitHub PR validation tool:" | |
echo "curl -sLO https://github.com/input-output-hk/offchain-metadata-tools/releases/download/v0.4.0.0/metadata-validator-github.tar.gz" | |
curl -sLO https://github.com/input-output-hk/offchain-metadata-tools/releases/download/v0.4.0.0/metadata-validator-github.tar.gz | |
echo | |
echo "Extracting the latest metadata GitHub PR validation tool:" | |
tar -zxvf metadata-validator-github.tar.gz | |
echo | |
echo "Running the metadata GitHub PR validator on this PR:" | |
echo | |
echo "./metadata-validator-github "${GITHUB_REPOSITORY_OWNER}" "$(cat "${GITHUB_EVENT_PATH}" | jq -r '.repository.name')" "${{ github.event.number }}" --expect-branch "${BASE}" --no-auth" | |
./metadata-validator-github "${GITHUB_REPOSITORY_OWNER}" "$(cat "${GITHUB_EVENT_PATH}" | jq -r '.repository.name')" "${{ github.event.number }}" --expect-branch "${BASE}" --no-auth | |
echo | |
echo "Obtaining the latest metadata validation tool:" | |
echo "curl -sLO https://github.com/input-output-hk/offchain-metadata-tools/releases/download/v0.4.0.0/token-metadata-creator.tar.gz" | |
curl -sLO https://github.com/input-output-hk/offchain-metadata-tools/releases/download/v0.4.0.0/token-metadata-creator.tar.gz | |
echo | |
echo "Extracting the latest metadata validation tool:" | |
tar -zxvf token-metadata-creator.tar.gz | |
echo | |
echo "Running the metadata validation tool on this PR:" | |
echo | |
VALIDATOR="./token-metadata-creator validate" | |
awk '/^M/ {print $2}' "pull-request/${GITHUB_SHA}.diff" | xargs --no-run-if-empty -- bash -c 'echo "$1 master/$2 pull-request/$2" && $1 master/$2 pull-request/$2' -- "$VALIDATOR" | |
awk '/^A/ {print $2}' "pull-request/${GITHUB_SHA}.diff" | xargs --no-run-if-empty -- bash -c 'echo "$1 pull-request/$2" && $1 pull-request/$2' -- "$VALIDATOR" | |
echo |