Skip to content

CI as a state of the art, part 3 #63

CI as a state of the art, part 3

CI as a state of the art, part 3 #63

name: Pull Request Entry Point
on:
pull_request:
env:
list-of-all-components: "[ 'gh-action', 'history-exporter' ]"
jobs:
check-permissions:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'run-no-ci') }}
uses: ./.github/workflows/90_helpers-check-permissions.yml
with:
github-event-name: ${{ github.event_name }}
workflows-sanity-checks:
needs: [ check-permissions ]
uses: ./.github/workflows/10_workflow-sanity-checks.yml
projects-changed:
needs: [ check-permissions, workflows-sanity-checks ]
name: Check source files for changes
runs-on: [ self-hosted, small ]
timeout-minutes: 2
outputs:
go-projects-changes: ${{ steps.go-projects-changes.outputs.changes }}
go-mod-changes: ${{ steps.go-projects-changes.outputs.go-mod }}
common-libs-changes: ${{ steps.go-projects-changes.outputs.common-libs }}
cmd-changes: ${{ steps.per-component-changes.outputs.cmd-changes }}
tests-changes: ${{ steps.per-component-changes.outputs.tests-changes }}
steps:
- uses: actions/checkout@v4
- name: Go Projects Changes
id: go-projects-changes
uses: dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242 #v3
with:
token: ${{ github.token }}
filters: .github/file-filters/go-components.yaml
base: ${{ github.event_name != 'pull_request' && (github.event.merge_group.base_ref || github.ref_name) || '' }}
ref: ${{ github.event_name != 'pull_request' && (github.event.merge_group.head_ref || github.ref) || '' }}
- name: Check per-component changes
id: per-component-changes
env:
PR_PATHS_CHANGES: ${{ steps.go-projects-changes.outputs.changes }}
CMDS_LIST: '["gh-action", "history-exporter"]'
TESTS_LIST: '["gh-action-tests", "history-exporter-tests"]'
run: |
cmd_changes=$(\
echo "$PR_PATHS_CHANGES" \
| jq --argsjson filter_list "$CMDS_LIST" \
'.[] | select( [.] | inside($filter_list) )' \
)
test_changes=$(\
echo "$PR_PATHS_CHANGES" \
| jq --argsjson filter_list "$TESTS_LIST" \
'.[] | select( [.] | inside($filter_list) )' \
)
echo "cmd-changes=${cmd_changes}" >> "${GITHUB_OUTPUT}"
echo "test-changes=${test_changes}" >> "${GITHUB_OUTPUT}"
build-go-projects:
needs: [ check-permissions, projects-changed ]
if: needs.projects-changed.outputs.go-projects-changes != '[]'
strategy:
matrix:
go-component: ${{ fromJson(needs.projects-changed.outputs.go-projects-changes) }}
uses: ./.github/workflows/50_go_build-one-component.yml
secrets: inherit
name: 'Golang: ${{ matrix.go-component }}'
with:
component-name: ${{ matrix.go-component }}
base-sha: ${{ github.event.pull_request.base.sha }}
head-sha: ${{ github.event.pull_request.head.sha }}
pack-to-docker-image: true
final-step:
needs: [ build-go-projects ]
if: ${{ always() }}
runs-on: [ self-hosted, small ]
steps:
- name: Print final message
run: |
echo Thats it.