-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (151 loc) · 5.16 KB
/
commit-data.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Copyright (C) 2023 Maxwell G <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or
# https://www.gnu.org/licenses/gpl-3.0.txt)
---
name: Verify upstreams and run sanity tests
on:
workflow_dispatch:
inputs:
major-version:
description: Major version of ansible
type: string
required: true
version:
description: Ansible version
type: string
required: true
push:
description: Whether to push data
type: boolean
default: true
sanity-tests:
description: Whether to run sanity test or only check upstreams
type: boolean
default: true
render-issues:
description: Whether to render sample issues\
type: boolean
default: true
jobs:
generate:
name: Generate data
runs-on: ubuntu-latest
defaults:
run:
working-directory: test_results
steps:
- name: Checkout test_results
uses: actions/checkout@v4
with:
path: test_results
ref: main
- name: Set up git committer
uses: gotmax23/[email protected]
with:
bot: github-actions
name: "Github Actions"
global: true
- name: Checkout ansible-build-data
uses: actions/checkout@v4
with:
repository: ansible-community/ansible-build-data
path: ansible-build-data
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Get ansible-core version
id: ansible-core
env:
data_path: "../ansible-build-data/${{ inputs.major-version }}/ansible-${{ inputs.version }}.deps"
run: |
version="$(grep '^_ansible_core_version:' "${data_path}" | awk '{ print $2 }')"
echo "version=${version}" > "${GITHUB_OUTPUT}"
- name: Install deps
env:
ansible_core: "ansible-core==${{ steps.ansible-core.outputs.version }}"
run: |
pip install -r requirements.txt "${ansible_core}"
- name: Verify upstreams
continue-on-error: true
env:
data_dir: "data/${{ inputs.major-version }}/"
data_path: "data/${{ inputs.major-version }}/ansible-${{ inputs.version }}-missing-upstreams.yaml"
tags_path: "../ansible-build-data/${{ inputs.major-version }}/ansible-${{ inputs.version }}-tags.yaml"
run: |
mkdir -p "${data_dir}"
antsibull-build verify-upstreams \
-O "${data_path}" --tree-dir build/unpack "${tags_path}"
- name: Run sanity tests
continue-on-error: true
if: "inputs.sanity-tests"
env:
data_path: "data/${{ inputs.major-version }}/ansible-${{ inputs.version }}-sanity.yaml"
run: |
antsibull-build sanity-tests -O "${data_path}" build/unpack/ansible_collections/*/*
- name: Render sample issues
if: "inputs.render-issues"
env:
sanity_path: "data/${{ inputs.major-version }}/ansible-${{ inputs.version }}-sanity.yaml"
missing_upstreams_path: "data/${{ inputs.major-version }}/ansible-${{ inputs.version }}-missing-upstreams.yaml"
tags_path: "../ansible-build-data/${{ inputs.major-version }}/ansible-${{ inputs.version }}-tags.yaml"
version: "${{ inputs.version }}"
run: >-
python ./main.py
--sanity-data "${sanity_path}"
--upstreams-data "${missing_upstreams_path}"
--tag-data "${tags_path}"
render-all
--output-dir "rendered/${version}"
--add-title
- name: Commit and create patch
env:
major_version: "${{ inputs.major-version }}"
version: "${{ inputs.version }}"
run: |
mkdir -p build/patches
touch build/patches/.keep
git diff || :
git add "data/${major_version}" rendered
if git diff-index --quiet HEAD ${{ inputs.changed-files }}; then
echo "Nothing to do"
exit
fi
git commit -m "data: update ${version}"
git format-patch -1 -o build/patches
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: build-patches
path: "test_results/build/patches/"
commit:
name: Commit and push data
runs-on: ubuntu-latest
permissions:
contents: write
if: "inputs.push"
needs:
- generate
steps:
- name: Checkout test_results
uses: actions/checkout@v4
with:
token: "${{ github.token }}"
ref: main
- name: Set up git committer
uses: gotmax23/[email protected]
with:
bot: github-actions
name: "Github Actions"
- name: Download patches
uses: actions/download-artifact@v3
with:
name: build-patches
path: build/patches
- name: Apply patches
run: |
if [ -n "$(find build/patches -type f -name '*.patch')" ]; then
git am --committer-date-is-author-date build/patches/*.patch
git push
fi