From 007d683bcb9da5e3f7b520ed11bcfb3e8fd92742 Mon Sep 17 00:00:00 2001 From: Chuang Zhang Date: Mon, 16 May 2022 14:21:05 +0800 Subject: [PATCH] Configure github action to build image JIRA: RHELWF-6471 --- .github/workflows/resultsdb.yaml | 113 +++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/workflows/resultsdb.yaml diff --git a/.github/workflows/resultsdb.yaml b/.github/workflows/resultsdb.yaml new file mode 100644 index 0000000..6b4744f --- /dev/null +++ b/.github/workflows/resultsdb.yaml @@ -0,0 +1,113 @@ +name: ResultsDB + +on: + pull_request: + push: + workflow_dispatch: + inputs: {} + +jobs: + tests: + name: Unit tests + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9"] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry tox tox-gh-actions + + - name: Test with tox + run: tox -e py + + - name: Run coveralls-python + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: python-${{ matrix.python-version }} + COVERALLS_PARALLEL: true + run: | + pip3 install --upgrade pip + pip3 install --upgrade setuptools + pip3 install --upgrade coveralls==3.2.0 + coveralls --service=github + + coveralls-finish: + name: Finish coveralls-python + needs: tests + runs-on: ubuntu-latest + steps: + - name: Finished + run: | + pip3 install --upgrade pip + pip3 install --upgrade setuptools + pip3 install --upgrade coveralls + coveralls --finish --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + hadolint: + name: Hadolint + runs-on: ubuntu-latest + strategy: + matrix: + dockerfile: + - Dockerfile + + steps: + - uses: actions/checkout@v2 + + - uses: hadolint/hadolint-action@v1.5.0 + with: + dockerfile: ${{ matrix.dockerfile }} + # Ignore list: + # * DL3041 - Specify version with dnf install -y - + ignore: DL3041 + failure-threshold: warning + + image-build: + name: Container Image Build + needs: hadolint + runs-on: ubuntu-latest + env: + IMAGE_NAME: resultsdb + REGISTRY: quay.io/factory2 + GH_REGISTRY: ghcr.io/${{ github.actor }} + + steps: + - uses: actions/checkout@v2 + + - name: Build Image + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.IMAGE_NAME }} + tags: >- + ${{ github.ref == 'refs/heads/master' && 'latest' || '' }} + ${{ github.sha }} + containerfiles: Dockerfile + + - name: Log in to the image registry + if: github.event_name == 'push' && github.actor != 'dependabot[bot]' + uses: redhat-actions/podman-login@v1 + with: + registry: ${{ secrets.REGISTRY_USER && env.REGISTRY || env.GH_REGISTRY }} + username: ${{ secrets.REGISTRY_USER || github.actor }} + password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }} + + - name: Push Image + if: github.event_name == 'push' && github.actor != 'dependabot[bot]' + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build-image.outputs.image }} + tags: ${{ steps.build-image.outputs.tags }} + registry: ${{ secrets.REGISTRY_USER && env.REGISTRY || env.GH_REGISTRY }}