Verify upstreams and run sanity tests #5
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
# Copyright (C) 2023 Maxwell G <maxwell@gtmx.me> | |
# 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 | |
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 | |
- name: Set up git committer | |
run: | | |
git config user.name "Github Actions" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- 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@v4 | |
with: | |
python-version: "3.11" | |
- name: Install deps | |
run: | | |
pip install -r requirements.txt | |
- name: Verify upstreams | |
continue-on-error: true | |
env: | |
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: | | |
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: 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}" | |
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" | |
steps: | |
- name: Checkout test_results | |
uses: actions/checkout@v4 | |
with: | |
token: "${{ github.token }}" | |
- name: Set up git committer | |
run: | | |
git config user.name "Github Actions" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- 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 | |