-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow_dispatch_with_input.yml
More file actions
104 lines (93 loc) · 5.32 KB
/
Copy pathworkflow_dispatch_with_input.yml
File metadata and controls
104 lines (93 loc) · 5.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ══════════════════════════════════════════════════════════════════════════════
# Run Tests by Tag — Manual Workflow with Input
#
# PURPOSE:
# The most flexible workflow in this project.
# It lets you type in any JUnit 5 tag (or combination of tags) at run-time
# and execute exactly those tests — without changing any code or YAML.
#
# TRIGGER:
# Manual only — triggered from the GitHub Actions UI:
# Actions tab → "Run Tests by Tag" → "Run workflow" → type tag(s) → Run
#
# INPUT:
# tags (optional) — the tag expression to pass to Maven's -Dgroups flag.
# Examples you can type in the UI:
# Rel1 → run only Rel1 tests
# Rel1 | Rel2 → run Rel1 OR Rel2 tests
# ecomm-unit-tests → run unit tests
# integration → run integration tests
# ecomm & integration → run tests with BOTH tags
# (leave blank) → run ALL tests
#
# HOW INPUTS WORK:
# "inputs" defined under workflow_dispatch are shown as form fields in the
# GitHub UI when you click "Run workflow". The values are then accessible
# in the workflow as: ${{ inputs.<input-name> }}
#
# RUN NAME:
# "run-name" customises the label shown for each workflow run in the UI.
# Here it shows the tags that were requested, making the run history readable
# e.g. "Run Tests by Tag — Rel1 | Rel2"
# "Run Tests by Tag — (all tests)"
# ══════════════════════════════════════════════════════════════════════════════
name: Run Tests by Tag
# ──────────────────────────────────────────────────────────────────────────────
# RUN NAME — shown in the Actions run history instead of a generic "Run #123".
# The ternary-style expression:
# inputs.tags != '' → show the tag value
# inputs.tags == '' → show "(all tests)"
# ──────────────────────────────────────────────────────────────────────────────
run-name: "Run Tests by Tag — ${{ inputs.tags != '' && inputs.tags || '(all tests)' }}"
# ──────────────────────────────────────────────────────────────────────────────
# TRIGGER
# workflow_dispatch with "inputs" creates a form in the GitHub UI.
# All inputs are optional here — leaving tags blank runs everything.
# ──────────────────────────────────────────────────────────────────────────────
on:
workflow_dispatch:
inputs:
tags:
description: |
JUnit 5 tag expression to run.
Examples:
Rel1 → single tag
Rel1 | Rel2 → OR (either tag)
ecomm & integration → AND (both tags)
(leave blank) → run ALL tests
required: false
default: ''
# ──────────────────────────────────────────────────────────────────────────────
# PERMISSIONS — read-only.
# ──────────────────────────────────────────────────────────────────────────────
permissions:
contents: read
jobs:
run-tagged-tests:
runs-on: ubuntu-latest
steps:
# STEP 1 — Checkout source code.
- name: Checkout repository
uses: actions/checkout@v4
# STEP 2 — Install JDK 21 with Maven cache.
- name: Set up JDK 21 (Temurin)
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
# STEP 3a — Run a SPECIFIC tag when the input is provided.
# The "if:" condition checks whether the tags input has a value.
# ${{ github.event.inputs.tags }} holds whatever the user typed in the UI.
- name: Run tests for specified tag(s)
if: ${{ github.event.inputs.tags != '' }}
run: |
echo "Running tests with tag filter: ${{ github.event.inputs.tags }}"
mvn test --no-transfer-progress --batch-mode -Dgroups="${{ github.event.inputs.tags }}"
# STEP 3b — Run ALL tests when no tag is specified.
# Only one of 3a or 3b will execute in any given run.
- name: Run ALL tests (no tag filter)
if: ${{ github.event.inputs.tags == '' }}
run: |
echo "No tag specified — running the full test suite"
mvn test --no-transfer-progress --batch-mode