set up reusable build and test workflow #15
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: "pipeline" | |
on: | |
push: | |
branches: ['main'] | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
description: 'dry run mode' | |
required: true | |
default: true | |
type: boolean | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
global_any_changed: ${{ steps.changed-files-yaml.outputs.global_any_changed }} | |
global_all_changed_files: ${{ steps.changed-files-yaml.outputs.global_all_changed_files }} | |
staging_area_all_changed_files: ${{ steps.changed-files-yaml.outputs.staging_area_all_changed_files }} | |
staging_area_any_changed: ${{ steps.changed-files-yaml.outputs.staging_area_any_changed }} | |
tests_all_changed_files: ${{ steps.changed-files-yaml.outputs.tests_all_changed_files }} | |
tests_any_changed: ${{ steps.changed-files-yaml.outputs.tests_any_changed }} | |
api_all_changed_files: ${{ steps.changed-files-yaml.outputs.api_all_changed_files }} | |
api_any_changed: ${{ steps.changed-files-yaml.outputs.api_any_changed }} | |
client_all_changed_files: ${{ steps.changed-files-yaml.outputs.client_all_changed_files }} | |
client_any_changed: ${{ steps.changed-files-yaml.outputs.client_any_changed }} | |
index_all_changed_files: ${{ steps.changed-files-yaml.outputs.index_all_changed_files }} | |
index_any_changed: ${{ steps.changed-files-yaml.outputs.index_any_changed }} | |
is_dry_run: ${{ steps.decide-on-dry-run.outputs.dry_run }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. | |
- name: Get all relevant file changes | |
id: changed-files-yaml | |
uses: tj-actions/changed-files@v42 | |
with: | |
files_yaml: | | |
global: | |
- '**' | |
staging_area: | |
- src/PackageRegistryServive/StagingArea/** | |
tests: | |
- tests/** | |
api: | |
- src/PackageRegistryServive/** | |
- '!src/PackageRegistryServive/StagingArea/**' | |
- '!src/PackageRegistryServive/Data/**' | |
client: | |
- src/AVPRClient/** | |
index: | |
- src/AVPRIndex/** | |
- name: decide on dry run | |
id: decide-on-dry-run | |
run: | | |
if [[ ${{ github.event_name == 'workflow_dispatch' }} == true ]]; then | |
dr=${{ inputs.dry-run }} | |
else | |
dr=false | |
fi | |
echo "dry_run=$dr" >> $GITHUB_OUTPUT | |
echo "$GITHUB_OUTPUT" | |
echo "dry_run=$dr" | |
- name: list outputs | |
run: | | |
echo "global:" | |
echo "- any: ${{ steps.changed-files-yaml.outputs.global_any_changed }}" | |
echo "- all: ${{ steps.changed-files-yaml.outputs.global_all_changed_files }}" | |
echo "staging area:" | |
echo "- any: ${{ steps.changed-files-yaml.outputs.staging_area_any_changed }}" | |
echo "- all: ${{ steps.changed-files-yaml.outputs.staging_area_all_changed_files }}" | |
echo "tests:" | |
echo "- any: ${{ steps.changed-files-yaml.outputs.tests_any_changed }}" | |
echo "- all: ${{ steps.changed-files-yaml.outputs.tests_all_changed_files }}" | |
echo "api:" | |
echo "- any: ${{ steps.changed-files-yaml.outputs.api_any_changed }}" | |
echo "- all: ${{ steps.changed-files-yaml.outputs.api_all_changed_files }}" | |
echo "client:" | |
echo "- any: ${{ steps.changed-files-yaml.outputs.client_any_changed }}" | |
echo "- all: ${{ steps.changed-files-yaml.outputs.client_all_changed_files }}" | |
echo "index:" | |
echo "- any: ${{ steps.changed-files-yaml.outputs.index_any_changed }}" | |
echo "- all: ${{ steps.changed-files-yaml.outputs.index_all_changed_files }}" | |
echo "dry run:" | |
echo "${{ steps.decide-on-dry-run.outputs.dry_run }}" | |
test_env: | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: list changes | |
run: | | |
echo "global:" | |
echo "- any: ${{ needs.setup.outputs.global_any_changed }}" | |
echo "- all: ${{ needs.setup.outputs.global_all_changed_files }}" | |
echo "staging area:" | |
echo "- any: ${{ needs.setup.outputs.staging_area_any_changed }}" | |
echo "- all: ${{ needs.setup.outputs.staging_area_all_changed_files }}" | |
echo "tests:" | |
echo "- any: ${{ needs.setup.outputs.tests_any_changed }}" | |
echo "- all: ${{ needs.setup.outputs.tests_all_changed_files }}" | |
echo "api:" | |
echo "- any: ${{ needs.setup.outputs.api_any_changed }}" | |
echo "- all: ${{ needs.setup.outputs.api_all_changed_files }}" | |
echo "client" | |
echo "- any: ${{ needs.setup.outputs.client_any_changed }}" | |
echo "- all: ${{ needs.setup.outputs.client_all_changed_files }}" | |
echo "index:" | |
echo "- any: ${{ needs.setup.outputs.index_any_changed }}" | |
echo "- all: ${{ needs.setup.outputs.index_all_changed_files }}" | |
echo "dry run:" | |
echo "${{ needs.setup.outputs.is_dry_run }}" | |
build: | |
needs: setup | |
if: ${{ needs.setup.outputs.tests_any_changed || needs.setup.outputs.api_any_changed || needs.setup.outputs.client_any_changed || needs.setup.outputs.index_any_changed}} | |
uses: nfdi4plants/arc-validate-package-registry/.github/workflows/build-and-test.yml@main |