# Repository for shared workflows for collection testing?

**URL:** <https://forum.ansible.com/t/repository-for-shared-workflows-for-collection-testing/3298>\
**Category:** Project Discussions\
**Tags:** github, testing, ci, community-wg, collections, galaxy-ng\
**Created:** [January 13, 2024, 4:00pm UTC](https://forum.ansible.com/t/repository-for-shared-workflows-for-collection-testing/3298 "2024-01-13T16:00:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 13, 2024, 4:00pm UTC](https://forum.ansible.com/t/repository-for-shared-workflows-for-collection-testing/3298/1 "2024-01-13T16:00:17Z")

</div>

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](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.](https://github.com/ansible-community/github-docs-build) (discussion for that: [Documentation build process · Issue #59 · ansible-community/community-topics · GitHub](https://github.com/ansible-community/community-topics/issues/59)).

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?

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 17, 2024, 7:20pm UTC](https://forum.ansible.com/t/repository-for-shared-workflows-for-collection-testing/3298/2 "2024-01-17T19:20:46Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 17, 2024, 9:42pm UTC](https://forum.ansible.com/t/repository-for-shared-workflows-for-collection-testing/3298/3 "2024-01-17T21:42:18Z")

</div>

The action repositories:

- [GitHub - ansible-community/github-action-build-collection](https://github.com/ansible-community/github-action-build-collection)
- [GitHub - ansible-community/github-action-test-galaxy-import](https://github.com/ansible-community/github-action-test-galaxy-import)

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](https://github.com/ansible-collections/community.hrobot/pull/95) 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](https://github.com/ansible-collections/community.hrobot/actions/runs/7562109367)

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

```yaml
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

```

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 17, 2024, 9:45pm UTC](https://forum.ansible.com/t/repository-for-shared-workflows-for-collection-testing/3298/4 "2024-01-17T21:45:40Z")

</div>

And here’s a workflow run for a collection with dependencies: [Use shared workflow for Galaxy import test · ansible-collections/community.routeros@0bcf112 · GitHub](https://github.com/ansible-collections/community.routeros/actions/runs/7562135039?pr=251)  
([PR](https://github.com/ansible-collections/community.routeros/pull/251))

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 21, 2024, 12:26pm UTC](https://forum.ansible.com/t/repository-for-shared-workflows-for-collection-testing/3298/5 "2024-01-21T12:26:50Z")

</div>

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