-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update coverage workflow to use containers (#81)
- Loading branch information
Showing
6 changed files
with
170 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
[run] | ||
omit = | ||
tests/* | ||
venv* | ||
branch = True | ||
source = scripts | ||
|
||
[report] | ||
fail_under = 80 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: build_and_publish_images | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build_and_publish: | ||
name: build-${{ matrix.el.distro }}${{ matrix.el.ver }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
el: | ||
- distro: centos | ||
ver: 7 | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
context: . | ||
file: ./Containerfiles/${{ matrix.el.distro }}${{ matrix.el.ver }}.Containerfile | ||
tags: ghcr.io/${{ github.repository_owner }}/convert2rhel-insights-tasks-${{ matrix.el.distro }}${{ matrix.el.ver }}:latest | ||
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/convert2rhel-insights-tasks-${{ matrix.el.distro }}${{ matrix.el.ver }}:latest | ||
cache-to: type=inline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,53 @@ | ||
name: Unit Tests | ||
name: test_coverage | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
branches: [main] | ||
pull_request: | ||
branches: [ main ] | ||
branches: [main] | ||
|
||
jobs: | ||
tests: | ||
coverage: | ||
name: coverage-${{ matrix.el.distro }}${{ matrix.el.ver }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
el: | ||
- distro: centos | ||
ver: 7 | ||
|
||
runs-on: ubuntu-latest | ||
container: | ||
image: python:2.7 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install requirements | ||
run: pip install --upgrade -r requirements.txt | ||
- name: Test | ||
run: python -m pytest --cov --cov-report=xml | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
fail_ci_if_error: true | ||
verbose: true # optional (default = false) | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Run pytest coverage | ||
run: | | ||
make tests${{ matrix.el.ver }} PYTEST_ARGS="--cov --cov-report xml --cov-report term" KEEP_TEST_CONTAINER=1 BUILD_IMAGES=0 | ||
podman cp pytest-container:/data/coverage.xml . | ||
- name: Upload coverage to Codecov | ||
id: UploadFirstAttempt | ||
continue-on-error: true | ||
uses: codecov/codecov-action@v4 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
with: | ||
env_vars: OS,PYTHON | ||
flags: ${{ matrix.el.distro }}-linux-${{ matrix.el.ver }} | ||
name: coverage-${{ matrix.el.distro }} | ||
fail_ci_if_error: true | ||
files: ./coverage.xml | ||
verbose: true # optional (default = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
**/__pycache__/** | ||
|
||
.coverage | ||
coverage.xml | ||
.build-image7 | ||
|
||
install-deps | ||
pre-commit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM centos:7 as base | ||
|
||
ENV PYTHON python2 | ||
ENV PIP pip | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
|
||
ENV URL_GET_PIP "https://bootstrap.pypa.io/pip/2.7/get-pip.py" | ||
ENV APP_DEV_DEPS "requirements.txt" | ||
|
||
WORKDIR /data | ||
|
||
FROM base as install_main_deps | ||
RUN yum update -y && yum clean all | ||
|
||
FROM install_main_deps as install_dev_deps | ||
COPY $APP_DEV_DEPS $APP_DEV_DEPS | ||
RUN curl $URL_GET_PIP | $PYTHON && $PIP install -r $APP_DEV_DEPS | ||
|
||
FROM install_dev_deps as install_application | ||
RUN groupadd --gid=1000 -r app && \ | ||
useradd -r --uid=1000 --gid=1000 app && \ | ||
chown -R app:app . | ||
|
||
COPY --chown=app:app . . | ||
USER app:app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters