From 99b25af46f97b8820c1058382eba5a6c9ca4e72f Mon Sep 17 00:00:00 2001 From: darkwizard242 Date: Thu, 18 May 2023 16:16:12 -0400 Subject: [PATCH] refactor CICD workflows --- .github/workflows/build-and-test.yml | 14 ++++++++------ .github/workflows/release.yml | 7 +++++-- requirements.txt | 11 +++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 requirements.txt diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4ccf8b6..b8a7209 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -15,6 +15,8 @@ on: schedule: - cron: '0 12 * * *' +env: + CUSTOM_DIR: 'darkwizard242.crictl' jobs: @@ -28,13 +30,13 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 with: - path: 'darkwizard242.crictl' + path: '${{ env.CUSTOM_DIR }}' fetch-depth: 0 - name: SonarCloud Scan uses: sonarsource/sonarcloud-github-action@master with: - projectBaseDir: 'darkwizard242.crictl' + projectBaseDir: '${{ env.CUSTOM_DIR }}' args: > -Dsonar.projectVersion=${{ github.ref }}_${{ github.run_number }} env: @@ -47,7 +49,7 @@ jobs: name: Build & Test runs-on: ubuntu-22.04 strategy: - max-parallel: 6 + max-parallel: 10 matrix: IMAGE: [ubuntu-22.04, ubuntu-20.04, ubuntu-18.04, rockylinux-8, centos-7, debian-bullseye, debian-buster] @@ -56,7 +58,7 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 with: - path: 'darkwizard242.crictl' + path: '${{ env.CUSTOM_DIR }}' - name: Set up Python 3.10 uses: actions/setup-python@v3 @@ -67,10 +69,10 @@ jobs: run: | sudo apt-get update sudo apt-get install python3-setuptools -y - pip3 install -U pip wheel ansible molecule molecule-plugins[docker] docker yamllint ansible-lint flake8 pytest-testinfra + pip3 install -U -r $CUSTOM_DIR/requirements.txt - name: Execute Molecule test of role for ${{ matrix.IMAGE }} - working-directory: 'darkwizard242.crictl' + working-directory: '${{ env.CUSTOM_DIR }}' run: DISTRO=${{ matrix.IMAGE }} molecule test env: PY_COLORS: '1' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acffd1a..1719cb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,9 @@ on: tags: - '*' +env: + CUSTOM_DIR: 'darkwizard242.crictl' + jobs: release: @@ -17,7 +20,7 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 with: - path: 'darkwizard242.awless' + path: '${{ env.CUSTOM_DIR }}' - name: Set up Python 3.10 uses: actions/setup-python@v3 @@ -31,5 +34,5 @@ jobs: pip3 install -U pip wheel ansible - name: Import to Ansible Galaxy. - working-directory: 'darkwizard242.awless' + working-directory: '${{ env.CUSTOM_DIR }}' run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} ${{ github.repository_owner }} $(echo ${{ github.repository }} | sed 's/.*\///') diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..21e23ef --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +pip +wheel +ansible +molecule +molecule-plugins[docker] +docker +yamllint +ansible-lint +flake8 +pytest-testinfra +requests<2.29.0