Skip to content

chore: fix merge conflicts #139

chore: fix merge conflicts

chore: fix merge conflicts #139

Workflow file for this run

name: PR CI
on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened
env:
GO111MODULE: on
GO_VERSION: 1.21
NODE_VERSION: 22
LINT_ARGS: -v --skip-files .*_test.go --timeout 5m0s --out-format colored-line-number
GOLANGCI_LINT_VERSION: v1.50
TEST_ARGS: -v -short -coverprofile=coverage.out
jobs:
validate_pr_title_job:
if: ${{ ! contains(github.head_ref, 'release-please--branches--main') }}
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: false
# Configure additional validation for the subject based on a regex.
# This example ensures the subject doesn't start with an uppercase character.
subjectPattern: ^(?![A-Z]).+$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
# Linting multiple Dockerfiles to ensure adherence to best practices and coding standards.
hadolint_job:
if: ${{ ! contains(github.head_ref, 'release-please--branches--main') }}
name: Hadolint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dockerfile:
- ./validator/docker/csv-validator/Dockerfile
- ./validator/docker/validator/Dockerfile
- ./validator/docker/xml-validator/Dockerfile
- ./registry/docker/compatibility-checker/Dockerfile
- ./registry/docker/initdb/Dockerfile
- ./registry/docker/registry/Dockerfile
- ./registry/docker/validity-checker/Dockerfile
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Run Hadolint for ${{ matrix.dockerfile }}
uses: hadolint/[email protected]
with:
config: ./.hadolint.yaml
dockerfile: ${{ matrix.dockerfile }}
editor_config_job:
if: ${{ ! contains(github.head_ref, 'release-please--branches--main') }}
name: Check editor config
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Editor Config
run: |
npm install --save-dev editorconfig-checker
./node_modules/.bin/editorconfig-checker
# Ensures that the code adheres to the lint checks defined in .golangci.yaml.
lint_job:
if: ${{ ! contains(github.head_ref, 'release-please--branches--main') }}
name: Go lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component:
- ./registry
- ./validator
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
# Using `tj-actions/changed-files` to check if any files in the component folder have changes
- name: Check if component folder has changed
id: check_changed_files
uses: tj-actions/changed-files@v45
with:
files: ${{ matrix.component }}/**
# Running lint steps if changes are detected in the component folder
- name: Set up Go
if: steps.check_changed_files.outputs.any_changed == 'true'
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
# Add all component folders for monorepos
cache-dependency-path: |
${{ matrix.component }}/go.sum
- name: Tidy Go mod for ${{ matrix.component }}
if: steps.check_changed_files.outputs.any_changed == 'true'
run: |
cd ${{ matrix.component }}
go mod tidy
- name: Run Go Lint for ${{ matrix.component }}
if: steps.check_changed_files.outputs.any_changed == 'true'
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
args: ${{env.LINT_ARGS}}
skip-cache: true
skip-save-cache: true
working-directory: ${{ matrix.component }}
licenses_check_job:
if: ${{ ! contains(github.head_ref, 'release-please--branches--main') }}
name: 3rd party licenses check
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Retrieve PR and branch info
run: |
PR_TITLE="chore: update 3rd-party licenses (#${{ github.event.number }})"
PR_INFO=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls?state=open" | \
jq --arg TITLE "$PR_TITLE" '.[] | select(.title == $TITLE) | { number: .number, head: .head.ref }')
echo "PR_INFO=$PR_INFO"
PR_NUMBER=$(echo "$PR_INFO" | jq -r .number)
BRANCH_NAME=$(echo "$PR_INFO" | jq -r .head)
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "BRANCH_NAME=${BRANCH_NAME:-update-third-party-licenses-${{ github.run_id }}}" >> $GITHUB_ENV
echo "PARENT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# if PR already exists
- name: Pull latest changes to existing branch
if: env.PR_NUMBER != ''
run: |
git fetch origin
git switch ${{ env.BRANCH_NAME }}
git pull origin ${{ env.PARENT_BRANCH }} --no-rebase
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
# Add all component folders for monorepos
cache-dependency-path: |
./registry/go.sum
./validator/go.sum
- name: Install Go licenses
run: go install github.com/google/[email protected]
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: '.github/workflows/requirements.txt'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r .github/workflows/requirements.txt
- name: Run go mod tidy, go mod vendor & license check
# switch to each component folder first
run: |
cd ./registry
go mod tidy
go mod vendor
go-licenses report ./... 2>/dev/null | python ../.github/workflows/generate_and_check_licenses.py
cd ../validator
go mod tidy
go mod vendor
go-licenses report ./... 2>/dev/null | python ../.github/workflows/generate_and_check_licenses.py
- name: Check and Commit changes
run: |
git add ./registry/licenses ./validator/licenses
if ! git diff-index --quiet HEAD; then
git commit -m "chore: update third party licenses"
echo "changes_committed=true" >> $GITHUB_ENV
else
echo "changes_committed=false" >> $GITHUB_ENV
fi
# This will fail if the incorrect go.mod or go.sum is committed
- name: Push changes
if: env.changes_committed == 'true'
run: |
git diff
if [[ -z "$PR_NUMBER" ]]; then
git switch -c ${{ env.BRANCH_NAME }}
fi
git push origin HEAD
- name: Create new PR
if: env.changes_committed == 'true' && env.PR_NUMBER == ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Creating a new PR..."
gh pr create --base "${{ env.PARENT_BRANCH }}" --head "update-third-party-licenses-${{ github.run_id }}" --title "${{ env.PR_TITLE }}" --body "This is an automated PR that updates the list of 3rd party licenses."
# Runs unit tests for all components in this repo
test_job:
if: ${{ ! contains(github.head_ref, 'release-please--branches--main') }}
name: Test job
runs-on: ubuntu-latest
strategy:
matrix:
component:
- ./registry
- ./validator
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
# Add all component folders for monorepos
cache-dependency-path: |
${{ matrix.component }}/go.sum
- name: Tidy Go mod for ${{ matrix.component }}
working-directory: ${{ matrix.component }}
run: go mod tidy
- name: Run Go Test for ${{ matrix.component }}
working-directory: ${{ matrix.component }}
run: go test ${{env.TEST_ARGS}} ./...
# Builds docker images for all components of the repo to test if they can successfully be built
test_docker_image_builds_job:
if: ${{ ! contains(github.head_ref, 'release-please--branches--main') }}
name: Test docker image builds
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component:
- dockerfile-path: ./validator/docker/csv-validator/Dockerfile
image-name: schema-registry-csv-val
- dockerfile-path: ./validator/docker/validator/Dockerfile
image-name: schema-registry-validator
- dockerfile-path: ./validator/docker/xml-validator/Dockerfile
image-name: schema-registry-xml-val
- dockerfile-path: ./registry/docker/compatibility-checker/Dockerfile
image-name: schema-registry-compatibility
- dockerfile-path: ./registry/docker/initdb/Dockerfile
image-name: schema-registry-initdb
- dockerfile-path: ./registry/docker/registry/Dockerfile
image-name: schema-registry-api
- dockerfile-path: ./registry/docker/validity-checker/Dockerfile
image-name: schema-registry-validity
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set Tag
run: |
TAG="build-docker-test"
echo "TAG=$TAG" >> $GITHUB_ENV # Exporting the TAG variable to the environment
- name: Build Docker image
run: |
docker build -t ${{ matrix.component.image-name }}:${{ env.TAG }} -f ${{ matrix.component.dockerfile-path }} .