Repository for shared workflows for collection testing?

I created a GHA workflow for community.docker that builds the collection and runs Galaxy importer on it: https://github.com/ansible-collections/community.docker/pull/754

It’s inspired from an earlier version I’ve been using in some of my collections which was more rudimentary (you had to specify the collection’s name, instead of extracting it from galaxy.yml, and it didn’t install collection requirements, so you had to modify to workflow to install them if you had any).

Instead of copying it over to other collections (which I currently did), I think it would be better to have this as a shared workflow somewhere that can be simply reused. For collection documentation building on GHA we have a repository with workflows: GitHub - ansible-community/github-docs-build: GitHub actions and workflows for building Ansible collection documentation. (discussion for that: Documentation build process · Issue #59 · ansible-community/community-topics · GitHub).

Do you also think this makes sense to have this as a shared workflow? And if yes, do you think there should be a specific repository for this shared workflow, or should we have a more generic repository which could have this as a shared workflow, and also some other collection CI related workflows?

1 Like

@gotmax23 suggested in the community meeting to bettre use composite actions, and have one action per repository. I’m tending to that now as well, and will also add a shared workflow to the repo to make re-use even easier (if you don’t have special needs).

In fact my workflow should be two distinct actions, building collections and importing them, so I’ll end up with two repos.

1 Like

The action repositories:

Both contain a shared workflow (see .github/workflows/) that makes reuse easier in certain scenarios.

Use shared workflow for Galaxy import test by felixfontein · Pull Request #95 · ansible-collections/community.hrobot · GitHub shows how to use the shared workflow of github-action-test-galaxy-import (which uses the shared workflow of github-action-build-collection to build the collection). One workflow run can be seen here: Use shared workflow for Galaxy import test · ansible-collections/community.hrobot@b7c5c1d · GitHub

The workflow in the collection is pretty simple due to reusing a shared workflow (I stripped some boilderplate):

name: import-galaxy
'on':
  # Run CI against all pushes (direct commits, also merged PRs) to main, and all Pull Requests
  push:
    branches:
      - main
      - stable-*
  pull_request:

jobs:
  import-galaxy:
    permissions:
      contents: read
    name: Test to import built collection artifact with Galaxy importer
    uses: ansible-community/github-action-test-galaxy-import/.github/workflows/test-galaxy-import.yml@main
1 Like

And here’s a workflow run for a collection with dependencies: Use shared workflow for Galaxy import test · ansible-collections/community.routeros@0bcf112 · GitHub
(PR)

I created Allow projects without third-party-check that publish to Galaxy by felixfontein · Pull Request #1845 · ansible/ansible-zuul-jobs · GitHub and Explicitly disable third-party-check for some collection repos by felixfontein · Pull Request #539 · ansible/zuul-config · GitHub to disable Zuul’s third-party-check for collection repositories that use the shared workflow from GitHub - ansible-community/github-action-test-galaxy-import on all their active branches.