Enable _tweak_price
for 3-coin Cryptopools
#1148
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 | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the main and develop branches. | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
branches: [ main, develop ] | |
jobs: | |
generate: | |
name: Generate comparison results | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} | |
- name: Set up latest Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install -r requirements.txt | |
- name: Generate comparison results | |
run: | | |
python3 -m test.simple_ci --generate | |
- name: Upload results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-data | |
path: test/data | |
package: | |
name: Test package (${{ matrix.py }} on ${{ matrix.os }}) | |
needs: generate | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
py: | |
- "3.11" | |
- "3.10" | |
- "3.9" | |
- "3.8" | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
exclude: | |
# Issue with python build | |
- os: windows-latest | |
py: "3.8" | |
# Intermittent CI test failures | |
- os: windows-latest | |
py: "3.11" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up latest Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.py }} | |
cache: 'pip' | |
- name: Build and install package | |
shell: bash | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install build | |
python3 -m build | |
python3 -m pip install dist/curvesim*.whl | |
# ensure tests hit installed package | |
rm -r curvesim | |
- name: Download comparison results | |
uses: actions/download-artifact@v3 | |
with: | |
name: test-data | |
path: test/data | |
- name: Hello world test | |
run: | | |
python3 -m curvesim | |
- name: End-to-end tests | |
run: | | |
python3 -m test.simple_ci | |
source: | |
name: Test source with coverage | |
needs: generate | |
runs-on: ubuntu-latest | |
permissions: | |
# Gives the action the necessary permissions for publishing new | |
# comments in pull requests. | |
pull-requests: write | |
# Gives the action the necessary permissions for pushing data to the | |
# python-coverage-comment-action branch, and for editing existing | |
# comments (to avoid publishing multiple comments in the same PR) | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up latest Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Unit tests | |
run: | | |
pytest --cov -n auto --cov-report= | |
- name: Download comparison results | |
uses: actions/download-artifact@v3 | |
with: | |
name: test-data | |
path: test/data | |
- name: End-to-end tests | |
run: | | |
coverage run -m test.simple_ci | |
- name: Download coverage badge | |
uses: chanhosuh/get-gist-action@master | |
id: covbadge | |
with: | |
gistURL: "https://gist.github.com/chanhosuh/3da3c072e081f4509ebdd09c63e6ede5" | |
- name: Coverage report | |
run: | | |
# combine coverage results from the previous steps | |
# and checks if score decreased since last CI run | |
coverage combine --append | |
BADGE_JSON=`cat ${{ steps.covbadge.outputs.file }}` | |
OLD_SCORE=$(python3 -c "import json; score=json.loads('${BADGE_JSON}')['message'].rstrip('%'); print(score)") | |
# Use a "band" around the old score to account for fluctuations | |
OLD_SCORE_LOWER=$((OLD_SCORE-1)) | |
OLD_SCORE_UPPER=$((OLD_SCORE+1)) | |
# Use low bound to test score doesn't decrease significantly | |
coverage report --fail-under="${OLD_SCORE_LOWER:-0}" | |
NEW_SCORE=$(coverage report --format=total) | |
# Save upper bound for comparison: only save score if increase is significant | |
echo "OLD_COVERAGE_SCORE=${OLD_SCORE_UPPER}" >> $GITHUB_ENV | |
echo "COVERAGE_SCORE=${NEW_SCORE}" >> $GITHUB_ENV | |
- name: Upload coverage badge | |
uses: schneegans/dynamic-badges-action@v1.6.0 | |
if: ${{ github.ref == 'refs/heads/main' && env.COVERAGE_SCORE > env.OLD_COVERAGE_SCORE }} | |
with: | |
auth: ${{ secrets.GIST_TOKEN }} # personal access token with scope "gist" | |
gistID: 3da3c072e081f4509ebdd09c63e6ede5 # id of previously created gist | |
filename: curvesim_coverage_badge.json | |
label: Coverage | |
message: ${{ env.COVERAGE_SCORE }}% | |
minColorRange: 50 | |
maxColorRange: 90 | |
valColorRange: ${{ env.COVERAGE_SCORE }}% | |
- name: Commit coverage report | |
id: coverage_comment | |
uses: py-cov-action/python-coverage-comment-action@v3 | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Store PR comment for posting | |
uses: actions/upload-artifact@v3 | |
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | |
with: | |
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly | |
name: python-coverage-comment-action | |
# If you use a different name, update COMMENT_FILENAME accordingly | |
path: python-coverage-comment-action.txt |