Skip to content

Commit

Permalink
next: new ci
Browse files Browse the repository at this point in the history
  • Loading branch information
akhercha committed Jul 5, 2024
1 parent 8b37e70 commit 2d8ff8a
Showing 1 changed file with 45 additions and 67 deletions.
112 changes: 45 additions & 67 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: CI/CD Pipeline

on:
push:
branches: [ main, master, development ]
branches: [ main, next ]
tags:
- 'v*'
pull_request:
branches: [ main, master, development ]
branches: [ main, next ]
schedule:
- cron: '0 0 * * *' # Daily at midnight UTC
workflow_dispatch:
Expand All @@ -21,35 +21,47 @@ 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: |
python -m pip install --upgrade pip
pip install poetry
poetry config installer.modern-installation false
- name: Set up Python 3.12
run: pipx install poetry
- name: Set up Python 3.12.4
uses: actions/setup-python@v4
with:
python-version: "3.12"
python-version: "3.12.4"
cache: 'poetry'
- name: Install dependencies
run: poetry install
run: |
cd ${{ matrix.package }}
poetry install
- name: Check poetry.lock
run: poetry lock --check
run: |
cd ${{ matrix.package }}
poetry lock --check
- name: Lint
run: poetry run poe lint
run: |
cd ${{ matrix.package }}
poetry run poe lint
- name: Format
run: poetry run poe format_check
run: |
cd ${{ matrix.package }}
poetry run poe format_check
- name: Typecheck
run: poetry run poe typecheck
run: |
cd ${{ matrix.package }}
poetry run poe typecheck
tests:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.12" ]
package: [pragma-utils, pragma-sdk, price-pusher, vrf-listener]
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -63,53 +75,19 @@ jobs:
python -m pip install --upgrade pip
pip install poetry
poetry config installer.modern-installation false
- name: Install python 3.12 requirements
run: |
poetry export -f requirements.txt --without-hashes --output requirements.txt
pip install -r requirements.txt
- name: Install dependencies
run: poetry install
- name: Cache contracts
id: cache-contracts
uses: actions/cache@v3
with:
path: ./pragma-oracle/target
key: ${{ runner.os }}-contracts-${{ hashFiles('./pragma-oracle/src', 'poetry.lock') }}
- uses: software-mansion/setup-scarb@v1
with:
tool-versions: pragma-oracle/.tool-versions
- name: Compile contracts
if: steps.cache-contracts.outputs.cache-hit != 'true'
working-directory: ./pragma-oracle
run: |
scarb -V
scarb build
- name: Check ABIs are up-to-date
run: |
for file in $(find ./pragma-oracle/target/dev -type f -name "*.sierra.json"); do
rel_path=${file#./pragma-oracle/target/dev}
diff "$file" "pragma/core/abis$rel_path" || (echo "Error: $rel_path in pragma-oracle/target does not match with pragma/core/abis/" && exit 1)
done
- name: Install rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Verify Rust and Cargo installation
run: |
rustc --version
cargo --version
- name: Install starknet-devnet
run: cargo install starknet-devnet
- name: Check circular imports
run: poetry run poe circular_imports_check
cd ${{ matrix.package }}
poetry install
# Add any package-specific setup steps here
- name: Run tests
env:
TESTNET_ACCOUNT_ADDRESS: ${{ secrets.TESTNET_ACCOUNT_ADDRESS }}
TESTNET_PRIVATE_KEY: ${{ secrets.TESTNET_PRIVATE_KEY }}
run: |
cd ${{ matrix.package }}
poetry run poe test_all
- name: Generate coverage in XML
run: poetry run coverage xml
run: |
cd ${{ matrix.package }}
poetry run coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
env:
Expand All @@ -119,34 +97,34 @@ jobs:
needs: [lint-format-typecheck, tests]
strategy:
matrix:
pkg: [sdk, price-pusher]
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
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- uses: actions/checkout@v3
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- name: Build package
run: |
cd ${{ matrix.pkg }}
cd ${{ matrix.package }}
poetry install --sync
poetry build
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.pkg }}-dist
path: ${{ matrix.pkg }}/dist
name: ${{ matrix.package }}-dist
path: ${{ matrix.package }}/dist

build_containers:
needs: build_packages
strategy:
matrix:
pkg: [price-pusher]
package: [price-pusher] # Add other packages that need containers here
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -161,12 +139,12 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: ${{ matrix.pkg }}-dist
path: ${{ matrix.pkg }}/dist
name: ${{ matrix.package }}-dist
path: ${{ matrix.package }}/dist
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./${{ matrix.pkg }}
context: ./${{ matrix.package }}
push: true
tags: ${{ env.IMAGE_SHA }}

Expand All @@ -188,7 +166,7 @@ jobs:
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*
run: twine upload **/dist/*
- name: Create Release
uses: actions/create-release@v1
env:
Expand Down

0 comments on commit 2d8ff8a

Please sign in to comment.