Skip to content

fix ci

fix ci #615

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, next ]
tags:
- 'v*'
pull_request:
branches: [ main, next ]
schedule:
- cron: '0 0 * * *' # Daily at midnight UTC
workflow_dispatch:
env:
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_HOST: tcp://docker:2376
DOCKER_DRIVER: overlay2
IMAGE_SHA: ${{ github.repository }}:${{ github.sha }}
jobs:
lint-format-typecheck:
name: Lint - Format - Typecheck
runs-on: ubuntu-latest
strategy:
matrix:
package: [pragma-utils, pragma-sdk, price-pusher, vrf-listener]
steps:
- uses: actions/checkout@v3
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.12.4
uses: actions/setup-python@v4
with:
python-version: "3.12.4"
cache: 'poetry'
- name: Install dependencies
run: |
cd ${{ matrix.package }}
poetry install
- name: Check poetry.lock
run: |
cd ${{ matrix.package }}
poetry lock --check
- name: Lint
run: |
cd ${{ matrix.package }}
poetry run poe lint
- name: Format
run: |
cd ${{ matrix.package }}
poetry run poe format_check
- name: Typecheck
run: |
cd ${{ matrix.package }}
poetry run poe typecheck
tests:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.12.4" ]
package: [pragma-utils, pragma-sdk, price-pusher, vrf-listener]
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- name: Install dependencies
run: |
cd ${{ matrix.package }}
poetry install
# Add any package-specific setup steps here
- name: Run tests
run: |
cd ${{ matrix.package }}
poetry run poe test_all
# TODO: re-add this
# - name: Generate coverage in XML
# run: |
# cd ${{ matrix.package }}
# poetry run coverage xml
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build_packages:
needs: [lint-format-typecheck, tests]
strategy:
matrix:
package: [pragma-utils, pragma-sdk, price-pusher, vrf-listener]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12.4
- uses: actions/checkout@v3
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- name: Build package
run: |
cd ${{ matrix.package }}
poetry install --sync
poetry build
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.package }}-dist
path: ${{ matrix.package }}/dist
build_containers:
needs: build_packages
strategy:
matrix:
package: [price-pusher] # Add other packages that need containers here
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: ${{ matrix.package }}-dist
path: ${{ matrix.package }}/dist
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./${{ matrix.package }}
push: true
tags: ${{ env.IMAGE_SHA }}
release:
needs: [build_packages, build_containers]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12.4
- name: Install twine
run: pip install --upgrade twine
- name: Download all artifacts
uses: actions/download-artifact@v2
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload **/dist/*
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: CHANGELOG.md
draft: false
prerelease: false
bump_version:
needs: [build_packages, build_containers]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12.4
- name: Install Commitizen
run: pip install --upgrade Commitizen
- name: Configure Git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Bump version
run: |
git fetch --tags
cz bump --retry || echo "probably nothing to do"
- name: Push changes
run: |
TAG=$(git tag --points-at HEAD)
if [[ $TAG ]]; then
echo "Version bumped to $TAG"
git push
git push --tags
else
echo "Version NOT bumped"
fi