-
Notifications
You must be signed in to change notification settings - Fork 9
107 lines (105 loc) · 4.33 KB
/
ci.yaml
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
105
106
107
name: CI
# base_ref / head_reaf are only available in PRs
on: [pull_request]
jobs:
dsl_ci:
runs-on: ubuntu-latest
name: Diff for DSL code
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Idenfify files changed in this PR
id: files
run: |
git fetch origin ${{ github.ref }}
git diff --name-only origin/${{ github.base_ref }}...FETCH_HEAD
echo "changed-files=$(git diff --name-only origin/${{ github.base_ref }}...FETCH_HEAD| tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Run testing on changed config files
id: dsl_check
run: |
for changed_file in ${{ steps.files.outputs.changed-files }}; do
if [[ ${changed_file} != ${changed_file/dsl\/*} ]]; then
echo "+ Detected at leat one config file: ${changed_file}."
echo "run_job=true" >> $GITHUB_OUTPUT
break
else
echo "run_job=false" >> $GITHUB_OUTPUT
fi
done
- name: Checkout
if: steps.dsl_check.outputs.run_job == 'true'
uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-java@v3
if: steps.dsl_check.outputs.run_job == 'true'
with:
distribution: 'temurin'
java-version: '11'
- name: Run release.py script tests
run: ./check_releasepy.bash
- name: Download and setup job dsl jar
if: steps.dsl_check.outputs.run_job == 'true'
run: ./jenkins-scripts/dsl/tools/setup_local_generation.bash
- name: Generate all DSL files
if: steps.dsl_check.outputs.run_job == 'true'
run: |
# simulate token for brew_release
sudo mkdir -p /var/lib/jenkins/ && sudo touch /var/lib/jenkins/remote_token
sudo chown -R ${USER} /var/lib/jenkins
cd jenkins-scripts/dsl
WRITE_JOB_LOG=1 java -jar tools/jobdsl.jar *.dsl
- name: Checks for DSL Code
if: steps.dsl_check.outputs.run_job == 'true'
run: |
cd jenkins-scripts/dsl
./dsl_checks.bash
- name: Export XML generated configuration for diff
if: steps.dsl_check.outputs.run_job == 'true'
run: |
cd jenkins-scripts/dsl
# export files for later diff
mkdir /tmp/pr_xml_configuration && mkdir /tmp/pr_log_generated/
# sort jobs.txt
sort jobs.txt -o jobs.txt
mv *.xml /tmp/pr_xml_configuration/
mv *.txt /tmp/pr_log_generated/
- name: Generate master DSL files
if: steps.dsl_check.outputs.run_job == 'true'
run: |
git clean -f -e jobdsl.jar
git checkout master
cd jenkins-scripts/dsl
WRITE_JOB_LOG=1 java -jar tools/jobdsl.jar *.dsl
mkdir /tmp/current_xml_configuration && mkdir /tmp/current_log_generated/
# sort jobs.txt
sort jobs.txt -o jobs.txt
mv *.xml /tmp/current_xml_configuration/
mv *.txt /tmp/current_log_generated/ || true
- name: Generating diffs
if: steps.dsl_check.outputs.run_job == 'true'
run: |
# somehow the Jenkins views changed the portlet_ id on every run.
diff -qr -I '.*<id>dashboard_portlet_.*</id>.*' /tmp/current_xml_configuration /tmp/pr_xml_configuration | sort > /tmp/xml_config_files_changed.diff || true
diff -ur -I '.*<id>dashboard_portlet_.*</id>.*' /tmp/current_xml_configuration /tmp/pr_xml_configuration > /tmp/xml_config_content_changed.diff || true
diff -ur /tmp/current_log_generated /tmp/pr_log_generated > /tmp/log_content_changed.diff || true
- name: Archive files changes
if: steps.dsl_check.outputs.run_job == 'true'
uses: actions/upload-artifact@v3
with:
name: xml_config_files_changed
path: /tmp/xml_config_files_changed.diff
- name: Archive content changes
if: steps.dsl_check.outputs.run_job == 'true'
uses: actions/upload-artifact@v3
with:
name: xml_config_content_changed
path: /tmp/xml_config_content_changed.diff
- name: Archive log changes
if: steps.dsl_check.outputs.run_job == 'true'
uses: actions/upload-artifact@v3
with:
name: log_content_changed
path: /tmp/log_content_changed.diff