Skip to content

feat(ci/cd): build/release pipeline #666

feat(ci/cd): build/release pipeline

feat(ci/cd): build/release pipeline #666

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [master, next]
tags:
- "v*"
pull_request:
branches: [master, next]
schedule:
- cron: "0 0 * * *" # Daily at midnight UTC
workflow_dispatch:
jobs:
lint-format-typecheck:
name: Lint - Format - Typecheck
continue-on-error: true
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
continue-on-error: true
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
- 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: |
# Find and compare *.sierra.json files in both directories
for file in $(find ./pragma-oracle/target/dev -type f -name "*.sierra.json"); do
# Extract the relative path of the file for comparison
rel_path=${file#./pragma-oracle/target/dev}
# Use diff to compare the file with its counterpart in the SDK directory
diff "$file" "pragma-sdk/pragma_sdk/onchain/abis$rel_path" || (echo "Error: $rel_path in pragma-oracle/target does not match with pragma-sdk/pragma_sdk/onchain/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
- uses: Swatinem/rust-cache@v2
- name: Install starknet-devnet
run: cargo install starknet-devnet
- name: Run tests
run: | # TODO(#000): remove that when CI is fixed
cd ${{ matrix.package }}
if [ "${{ matrix.package }}" = "pragma-sdk" ]; then
poetry run poe test_client
poetry run poe test_vrf
poetry run poe test_fetchers
poetry run poe test_all_unit
else
poetry run poe test_all
fi
- 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 }}