Skip to content

Verify upstreams and run sanity tests #19

Verify upstreams and run sanity tests

Verify upstreams and run sanity tests #19

Workflow file for this run

# 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
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: 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"
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