From 7d7b744789fa389d1cecae75a681ab4787cf0115 Mon Sep 17 00:00:00 2001 From: Sean Sullivan Date: Mon, 5 Dec 2022 21:00:23 -0800 Subject: [PATCH] update workflows (#50) --- .github/workflow-config/create_changelog.yml | 33 -------- .github/workflow-config/release.yml | 49 ------------ .github/workflow-config/release_tarball.yml | 37 --------- .github/workflows/automerge-release.yml | 20 ----- .github/workflows/cop-galaxy-release.yml | 32 -------- .github/workflows/create_changelog.yml | 59 -------------- .github/workflows/infra-galaxy-release.yml | 37 --------- .github/workflows/pre-commit.yml | 36 ++++++--- .github/workflows/release.yml | 78 +++++++++++++++++++ .github/workflows/tarball-release.yml | 69 ---------------- .pre-commit-config.yaml | 4 +- roles/ee_builder/tasks/00_build_ee.yml | 3 +- roles/ee_builder/tasks/main.yml | 2 +- roles/virtualenv_migrate/tasks/01_ee_diff.yml | 2 +- roles/virtualenv_migrate/tasks/main.yml | 6 +- 15 files changed, 112 insertions(+), 355 deletions(-) delete mode 100644 .github/workflow-config/create_changelog.yml delete mode 100644 .github/workflow-config/release.yml delete mode 100644 .github/workflow-config/release_tarball.yml delete mode 100644 .github/workflows/automerge-release.yml delete mode 100644 .github/workflows/cop-galaxy-release.yml delete mode 100644 .github/workflows/create_changelog.yml delete mode 100644 .github/workflows/infra-galaxy-release.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/tarball-release.yml diff --git a/.github/workflow-config/create_changelog.yml b/.github/workflow-config/create_changelog.yml deleted file mode 100644 index eca78b3..0000000 --- a/.github/workflow-config/create_changelog.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- name: release collection - hosts: localhost - gather_facts: False - connection: local - vars: - collection_namespace: "{{ namespace | lower | regex_replace('-','_') }}" - collection_name: ee_utilities - collection_version: "{{ github_tag | regex_search('(\\d.\\d.\\d.*)') }}" - collection_repo: undef - api_key: undef - repo_base_dir: "{{ playbook_dir }}/../.." - - tasks: - - name: create galaxy.yml - template: - src: "{{ repo_base_dir }}/galaxy.yml.j2" - dest: "{{ repo_base_dir }}/galaxy.yml" - mode: '0644' - - - name: Update changelog - command: - cmd: antsibull-changelog release --verbose --version {{ collection_version }} - chdir: "{{ repo_base_dir }}" - register: update_changelog - changed_when: "update_changelog.rc != 2" - - - name: remove galaxy.yml - file: - path: "{{ repo_base_dir }}/galaxy.yml" - state: absent - tags: cleanup -... diff --git a/.github/workflow-config/release.yml b/.github/workflow-config/release.yml deleted file mode 100644 index abe39cd..0000000 --- a/.github/workflow-config/release.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- name: release collection - hosts: localhost - gather_facts: false - connection: local - vars: - collection_namespace: "{{ namespace | lower | regex_replace('-','_') }}" - collection_name: ee_utilities - collection_version: "{{ github_tag | regex_search('(\\d.\\d.\\d.*)') }}" - collection_repo: undef - api_key: undef - repo_base_dir: "{{ playbook_dir }}/../.." - - tasks: - - name: create galaxy.yml - template: - src: "{{ repo_base_dir }}/galaxy.yml.j2" - dest: "{{ repo_base_dir }}/galaxy.yml" - - - name: build collection - command: - cmd: ansible-galaxy collection build - chdir: "{{ repo_base_dir }}" - creates: "{{ repo_base_dir }}/{{ collection_namespace }}-{{ collection_name }}-{{ collection_version }}.tar.gz" - tags: build - - - name: install collection - command: - cmd: "ansible-galaxy collection install {{ collection_namespace }}-{{ collection_name }}-{{ collection_version }}.tar.gz -p ~/.ansible/collections/" - chdir: "{{ repo_base_dir }}" - tags: install - - - name: Pause for 30 seconds. #so it is on different cadence then the redhat_cop one. - ansible.builtin.pause: - seconds: 30 - when: collection_namespace == "infra" - - - name: publish collection - command: - cmd: "ansible-galaxy collection publish --api-key={{ api_key }} {{ collection_namespace }}-{{ collection_name }}-{{ collection_version }}.tar.gz" - chdir: "{{ repo_base_dir }}" - tags: publish - - - name: remove galaxy.yml - file: - path: "{{ repo_base_dir }}/galaxy.yml" - state: absent - tags: cleanup -... diff --git a/.github/workflow-config/release_tarball.yml b/.github/workflow-config/release_tarball.yml deleted file mode 100644 index 7fc5bca..0000000 --- a/.github/workflow-config/release_tarball.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: release collection - hosts: localhost - gather_facts: False - connection: local - vars: - collection_namespace: "{{ namespace | lower | regex_replace('-','_') }}" - collection_name: ee_utilities - collection_version: "{{ github_tag | regex_search('(\\d.\\d.\\d.*)') }}" - collection_repo: undef - api_key: undef - repo_base_dir: "{{ playbook_dir }}/../.." - - tasks: - - name: create galaxy.yml - template: - src: "{{ repo_base_dir }}/galaxy.yml.j2" - dest: "{{ repo_base_dir }}/galaxy.yml" - mode: '0644' - - - name: build collection - command: - cmd: ansible-galaxy collection build - chdir: "{{ repo_base_dir }}" - creates: "{{ repo_base_dir }}/{{ collection_namespace }}-{{ collection_name }}-{{ collection_version }}.tar.gz" - register: build_result - changed_when: "build_result.rc != 2" - tags: build - - - name: install collection - command: - cmd: "ansible-galaxy collection install {{ collection_namespace }}-{{ collection_name }}-{{ collection_version }}.tar.gz -p ~/.ansible/collections/" - chdir: "{{ repo_base_dir }}" - register: install_result - changed_when: "install_result.rc != 2" - tags: install -... diff --git a/.github/workflows/automerge-release.yml b/.github/workflows/automerge-release.yml deleted file mode 100644 index f2056ef..0000000 --- a/.github/workflows/automerge-release.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Merge Bot - -on: - pull_request: - types: - - labeled - -jobs: - merge: - runs-on: ubuntu-latest - name: Merge - steps: - - name: Merge changelog automated PR - uses: squalrus/merge-bot@master - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - labels: changelog, automated pr - reviewers: false -... diff --git a/.github/workflows/cop-galaxy-release.yml b/.github/workflows/cop-galaxy-release.yml deleted file mode 100644 index 335b122..0000000 --- a/.github/workflows/cop-galaxy-release.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: cop-galaxy-release -on: # yamllint disable-line rule:truthy - release: - types: - - published - -jobs: - release: - runs-on: ubuntu-latest - env: - ANSIBLE_FORCE_COLOR: 1 - steps: - - name: Check out code - uses: actions/checkout@v1 - - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: Install ansible-base - run: pip install ansible - - - name: Publish to galaxy - run: ansible-playbook .github/workflow-config/release.yml - -e namespace=${{ github.repository_owner }} - -e github_tag=${{ github.ref_name }} - -e api_key=${{ secrets.ANSIBLE_GALAXY_APIKEY }} - -e collection_repo=https://github.com/${{ github.repository }} - --skip-tags=install,cleanup -... diff --git a/.github/workflows/create_changelog.yml b/.github/workflows/create_changelog.yml deleted file mode 100644 index 13a66a1..0000000 --- a/.github/workflows/create_changelog.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- -name: Create Changelog -on: # yamllint disable-line rule:truthy - release: - types: - - published - -jobs: - release: - runs-on: ubuntu-latest - env: - ANSIBLE_FORCE_COLOR: 1 - steps: - - name: Check out code - uses: actions/checkout@v1 - - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: Install ansible-base - run: pip install ansible - - - name: Install ansible-base and changelog - run: pip install ansible antsibull-changelog - - - name: Create Changelog - run: ansible-playbook .github/workflow-config/create_changelog.yml - -e namespace=${{ github.repository_owner }} - -e github_tag=${{ github.ref_name }} - -e api_key=${{ secrets.ANSIBLE_GALAXY_APIKEY }} - -e collection_repo=https://github.com/${{ github.repository }} - --skip-tags=install,cleanup - - - name: Create Pull Request - id: prcreate - uses: peter-evans/create-pull-request@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update changelog ${{ github.ref }} - committer: GitHub - author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - signoff: false - base: devel - branch: changelog-patches - delete-branch: true - title: '[RELEASE] Update changelog ${{ github.ref }}' - body: | - Update changelog - - Updated with changelog for release ${{ github.ref }} - - Auto-generated by [create-pull-request][1] - - [1]: https://github.com/peter-evans/create-pull-request - labels: | - changelog - automated pr - draft: false -... diff --git a/.github/workflows/infra-galaxy-release.yml b/.github/workflows/infra-galaxy-release.yml deleted file mode 100644 index 3d05922..0000000 --- a/.github/workflows/infra-galaxy-release.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: infra-galaxy-release -on: - release: - types: - - published - -jobs: - release: - runs-on: ubuntu-latest - env: - ANSIBLE_FORCE_COLOR: 1 - steps: - - name: Check out code - uses: actions/checkout@v1 - with: - persist-credentials: false - fetch-depth: 0 - - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: Install ansible-base - run: pip install ansible - - - name: Publish to galaxy - run: ansible-playbook .github/workflow-config/release.yml - -e namespace='infra' - -e github_tag=${{ github.ref_name }} - -e api_key=${{ secrets.GALAXY_INFRA_KEY }} - -e collection_repo=https://github.com/${{ github.repository }} - --verbose --skip-tags=install,cleanup - - -... diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index b1d776b..d71a19a 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,19 +1,35 @@ --- # This workflow action will run pre-commit, which will execute ansible and yaml linting -# See .pre-commit-config.yml for what hooks are executed -name: Yaml and Ansible Lint +# See .pre-commit-config.yaml for what hooks are executed +name: pre-commit tests -on: [push, pull_request] # yamllint disable-line rule:truthy + +on: + pull_request: + push: + schedule: + - cron: "0 6 * * *" jobs: pre-commit: + uses: "redhat-cop/ansible_collections_tooling/.github/workflows/pre-commit.yml@main" + sanity: + uses: "redhat-cop/ansible_collections_tooling/.github/workflows/sanity.yml@main" + with: + collection_namespace: infra + collection_name: ee_utilities + collection_version: 1.0.0 + collection_repo: https://github.com/redhat-cop/ee_utilities/ + all_green: + if: ${{ always() }} + needs: + - pre-commit + - sanity runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - name: Install Collections - run: | - sudo apt install software-properties-common - pip install --upgrade ansible - - uses: pre-commit/action@v2.0.0 + - run: >- + python -c "assert set([ + '${{ needs.pre-commit.result }}', + '${{ needs.sanity.result }}', + ]) == {'success'}" ... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fbc6d50 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +--- +# This workflow action will run pre-commit, which will execute ansible and yaml linting +# See .pre-commit-config.yaml for what hooks are executed +name: Release + +on: + release: + types: + - published + +jobs: + pre-commit: + uses: redhat-cop/ansible_collections_tooling/.github/workflows/pre-commit.yml@main + sanity: + uses: redhat-cop/ansible_collections_tooling/.github/workflows/sanity.yml@main + with: + collection_namespace: infra + collection_name: ee_utilities + collection_version: 1.0.0 + collection_repo: https://github.com/redhat-cop/ee_utilities/ + prechecks: + needs: + - pre-commit + - sanity + runs-on: ubuntu-latest + steps: + - run: >- + python -c "assert set([ + '${{ needs.pre-commit.result }}', + '${{ needs.sanity.result }}', + ]) == {'success'}" + cop_release: + needs: + - prechecks + uses: redhat-cop/ansible_collections_tooling/.github/workflows/release.yml@main + with: + collection_namespace: redhat_cop + collection_name: ee_utilities + collection_version: ${{ github.ref_name }} + collection_repo: https://github.com/redhat-cop/ee_utilities/ + secrets: + api_key: ${{ secrets.ANSIBLE_GALAXY_APIKEY }} + token: ${{ secrets.GITHUB_TOKEN }} + infra_release: + needs: + - cop_release + uses: redhat-cop/ansible_collections_tooling/.github/workflows/release.yml@main + with: + collection_namespace: infra + collection_name: ee_utilities + collection_version: ${{ github.ref_name }} + collection_repo: https://github.com/redhat-cop/ee_utilities/ + secrets: + api_key: ${{ secrets.GALAXY_INFRA_KEY }} + token: ${{ secrets.GITHUB_TOKEN }} + release_check: + needs: + - cop_release + - infra_release + runs-on: ubuntu-latest + steps: + - run: >- + python -c "assert set([ + '${{ needs.infra_release.result }}', + '${{ needs.cop_release.result }}', + ]) == {'success'}" + changelog: + needs: + - release_check + uses: redhat-cop/ansible_collections_tooling/.github/workflows/create_changelog.yml@main + with: + collection_namespace: infra + collection_name: ee_utilities + collection_version: ${{ github.ref_name }} + collection_repo: https://github.com/redhat-cop/ee_utilities/ + secrets: + token: ${{ secrets.GITHUB_TOKEN }} +... diff --git a/.github/workflows/tarball-release.yml b/.github/workflows/tarball-release.yml deleted file mode 100644 index 8fbfdb7..0000000 --- a/.github/workflows/tarball-release.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -name: tarball-release -on: - push: - tags: - - '*' - -jobs: - release: - runs-on: ubuntu-latest - env: - ANSIBLE_FORCE_COLOR: 1 - steps: - - name: Check out code - uses: actions/checkout@v1 - with: - persist-credentials: false - fetch-depth: 0 - - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: redhat_cop tarball creation - run: ansible-playbook .github/workflow-config/release_tarball.yml - -e namespace=${{ github.repository_owner }} - -e github_tag=${{ github.ref_name }} - -e collection_repo=https://github.com/${{ github.repository }} - --verbose --skip-tags=install,cleanup - - - name: infra tarball creation - run: ansible-playbook .github/workflow-config/release_tarball.yml - -e namespace=infra - -e github_tag=${{ github.ref_name }} - -e collection_repo=https://github.com/${{ github.repository }} - --verbose --skip-tags=install,cleanup - - - name: run ls - run: ls - - - name: Set namespace - run: | - echo "NAMESPACE=$(sed 's/-/_/g' <<< ${{ github.repository_owner }})" >> $GITHUB_OUTPUT - id: namespace - - - name: Display namespace - run: echo "namespace is ${{ steps.namespace.outputs.NAMESPACE }}" - - - name: run ls - run: ls - - - name: Upload files to tag - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: infra-ee_utilities-${{ github.ref_name }}.tar.gz - tag: ${{ github.ref }} - overwrite: true - - - name: Upload files to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ steps.namespace.outputs.NAMESPACE }}-ee_utilities-${{ github.ref_name }}.tar.gz - tag: ${{ github.ref }} - overwrite: true - -... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index faa956a..0708eaf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/ansible-community/ansible-lint.git - rev: v6.6.1 + rev: v6.9.1 hooks: # see discussions here about what arguments are used, and behavior # https://github.com/ansible/ansible-lint/issues/649 diff --git a/roles/ee_builder/tasks/00_build_ee.yml b/roles/ee_builder/tasks/00_build_ee.yml index 3f8d494..8ad8bc8 100644 --- a/roles/ee_builder/tasks/00_build_ee.yml +++ b/roles/ee_builder/tasks/00_build_ee.yml @@ -1,6 +1,7 @@ --- # tasks file for ee_builder - name: Build directory creation block. + when: builder_dir is not defined block: - name: Create temporary folder ansible.builtin.tempfile: @@ -12,8 +13,6 @@ ansible.builtin.set_fact: builder_dir: "{{ build_dir.path }}" - when: builder_dir is not defined - - name: Pull builder images containers.podman.podman_image: name: "{{ item }}" diff --git a/roles/ee_builder/tasks/main.yml b/roles/ee_builder/tasks/main.yml index 7d25156..4de2fa0 100644 --- a/roles/ee_builder/tasks/main.yml +++ b/roles/ee_builder/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Build EE environments - include_tasks: 00_build_ee.yml + ansible.builtin.include_tasks: 00_build_ee.yml loop: "{{ ee_list }}" loop_control: loop_var: __execution_environment_definition diff --git a/roles/virtualenv_migrate/tasks/01_ee_diff.yml b/roles/virtualenv_migrate/tasks/01_ee_diff.yml index 69c6e25..f4329da 100644 --- a/roles/virtualenv_migrate/tasks/01_ee_diff.yml +++ b/roles/virtualenv_migrate/tasks/01_ee_diff.yml @@ -1,5 +1,6 @@ --- - name: Diff with EE requirements + delegate_to: localhost block: - name: Diff | Download the default EE on localhost containers.podman.podman_image: @@ -25,5 +26,4 @@ - name: Diff | Show the packages that are extra from default EEs in custom venvs. ansible.builtin.debug: msg: "{{ venv_migrate_ee_python_list }}" - delegate_to: localhost ... diff --git a/roles/virtualenv_migrate/tasks/main.yml b/roles/virtualenv_migrate/tasks/main.yml index a1b213f..67e7fc0 100644 --- a/roles/virtualenv_migrate/tasks/main.yml +++ b/roles/virtualenv_migrate/tasks/main.yml @@ -1,12 +1,12 @@ --- - name: Gather custom venv requirements - include_tasks: 00_gather_custom_requirements.yml + ansible.builtin.include_tasks: 00_gather_custom_requirements.yml - name: Diff with EE requirements - include_tasks: 01_ee_diff.yml + ansible.builtin.include_tasks: 01_ee_diff.yml - name: Create EE list - include_tasks: 02_ee_list_create.yml + ansible.builtin.include_tasks: 02_ee_list_create.yml loop: "{{ __venv_migrate_combined_requirements_ser }}" loop_control: loop_var: __venv_migrate_python_item