Merge pull request #483 from tdspora/EPMCTDM-7179_target_validation_f… #2713
Workflow file for this run
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
name: CI/CD | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
# Compare requirement files | |
- name: Compare requirement files | |
run: | | |
# Extract requirements from setup.cfg, remove leading spaces, and store in req_compare.txt | |
sed -n '/install_requires/,/^\[/{//!p}' setup.cfg | awk '/^ *$/ { next; } { print; }' | sed 's/^ //' > req_compare.txt | |
# Compare req_compare.txt with requirements.txt | |
# If files are different, echo the differences and exit with error status | |
if DIFF=$(diff req_compare.txt requirements.txt) ; then | |
echo "Files are the same" | |
else | |
echo "Files are different:" | |
diff req_compare.txt requirements.txt | |
exit 1 | |
fi | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Test with pytest | |
run: | | |
pip install -e . && pytest src/tests | |
build-and-publish: | |
needs: test | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build Package | |
run: python -m build . | |
- name: Publish package | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} # For testing purposes: use secrets.PYPI_TEST_TOKEN | |
print_hash: true | |
verbose: true | |
docker: | |
needs: test | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: tdspora | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta (BASE) | |
id: docker_meta_base | |
uses: docker/metadata-action@v5 | |
with: | |
images: tdspora/syngen | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{raw}} | |
- name: Build and push (BASE) | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.docker_meta_base.outputs.tags }} | |
labels: ${{ steps.docker_meta_base.outputs.labels }} | |
cache-from: type=registry,ref=tdspora/syngen:buildcache | |
cache-to: type=registry,ref=tdspora/syngen:buildcache,mode=max |