-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (69 loc) · 3.51 KB
/
Copy pathvalidate.yaml
File metadata and controls
85 lines (69 loc) · 3.51 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
on:
pull_request:
types: [labeled]
permissions:
pull-requests: write
# Ensures that multiple validation job runs do not execute concurrently on the same PR.
# If a new run is triggered, any in-progress run for the same group is canceled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
multiple-labels:
runs-on: ubuntu-latest
steps:
- name: Check Labels
run: |
COUNT=$(echo '${{ toJson(github.event.pull_request.labels) }}' | jq '[.[] | select(.name | test("run-full-validation|run-full-validation-long|run-quick-validation"))] | length')
if [[ "$COUNT" -gt 1 ]]; then
echo "More than one validation label found. Failing the job."
exit 1
fi
shell: bash
# multiple-labels:
# name: 'Check that only one validation label is applied'
# if: >
# (contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-full-validation-long')) ||
# (contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation')) ||
# (contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation'))
# runs-on: ubuntu-latest
# steps:
# - env:
# GH_TOKEN: ${{ secrets.GH_PAT }}
# run: |
# echo "Multiple validation labels detected. Removing labels..."
# # Remove appropriate labels based on which ones are present
# if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') }}" == "true" ]]; then
# gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-full-validation-long"
# fi
# if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-full-validation') }}" == "true" ]]; then
# gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-full-validation"
# fi
# if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-quick-validation') }}" == "true" ]]; then
# gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-quick-validation"
# fi
# echo "Completed label cleanup"
# exit 1
validate:
name: 'Validate Changed Packages - Github Hosted'
runs-on: ubuntu-latest
if: >
contains(github.event.pull_request.labels.*.name, 'run-full-validation') ||
contains(github.event.pull_request.labels.*.name, 'run-quick-validation')
# if: >
# contains(github.event.pull_request.labels.*.name, 'run-full-validation') &&
# !contains(github.event.pull_request.labels.*.name, 'run-full-validation-long')
steps:
- name: Run Validation Script
run: |
echo "Running validation because 'full validation' label was added"
# Add your validation logic here (e.g., linting, testing)
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-quick-validation') }}" == "true" ]]; then
# Perform validation in 'Individual" mode
echo "Running Quick Validation..."
else
# Perform validation in 'Thorough' mode
echo "Running Full Validation..."
fi
sleep 5
exit 0