Skip to content

Commit

Permalink
feat: gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Feb 25, 2023
1 parent 8826d0d commit 74fa7b8
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master, dev ]
paths:
- '**.py'
- '**/codeql-analysis.yml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, dev ]
paths:
- '**.py'
- '**/codeql-analysis.yml'
schedule:
- cron: '41 4 * * 2'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
94 changes: 94 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: PyTest

on:
push:
branch: dev
paths:
- '**.py'
- '**/pytest.yaml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, dev ]
paths:
- '**.py'
- '**/pytest.yaml'

jobs:
test:
runs-on: ${{ matrix.os }}
#timeout-minutes: 10
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
network: [ mainnet, bsc-main, polygon-main, ftm-main ]
include:
- os: ubuntu-latest
path: ~/.cache/pip
- os: macos-latest
path: ~/Library/Caches/pip
- os: windows-latest
path: ~\AppData\Local\pip\Cache
- network: mainnet
provider: WEB3_PROVIDER
- network: bsc-main
provider: BSC_WEB3_PROVIDER
- network: polygon-main
provider: POLY_WEB3_PROVIDER
- network: ftm-main
provider: FTM_WEB3_PROVIDER


steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Setup Python (faster than using Python container)
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: Cache dependencies
uses: actions/cache@v3
with:
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-dev.txt') }}
path: |
${{ matrix.path }}
- name: Cache joblib middleware cache
uses: actions/cache@v3
with:
# Include requirements.txt so we recache if web3 version changes
key: forceupdatedeletethislater3-${{ runner.os }}-${{ matrix.network }}-${{ hashFiles('**/middleware.py') }}-${{ hashFiles('**/requirements.txt') }}
path: |
./cache/*/joblib/web3/middleware/filter/middleware
- name: Install dependencies
run: |
pip install -r requirements-dev.txt
pip install -r requirements.txt
- name: Setup brownie networks
run: |
brownie networks modify ${{ matrix.network }} host=${{ secrets[matrix.provider] }}
continue-on-error: true

- name: Cache compilers and brownie deployments
uses: actions/cache@v3
with:
key: forceupdatedeletethislater3-${{ runner.os }}-brownie-cache-${{ matrix.network }}
path: |
~/.brownie/deployments.db
~/.solcx
~/.vvm
- name: Run test suite
env:
BROWNIE_NETWORK: ${{ matrix.network }}
# Explorer tokens for all chains:
ETHERSCAN_TOKEN: ${{ secrets.ETHERSCAN_TOKEN }}
BSCSCAN_TOKEN: ${{ secrets.BSCSCAN_TOKEN }}
POLYGONSCAN_TOKEN: ${{ secrets.POLYGONSCAN_TOKEN }}
FTMSCAN_TOKEN: ${{ secrets.FTMSCAN_TOKEN }}
run: make test
continue-on-error: true

31 changes: 31 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Upload Python Package

on:
push:
branches:
- dev
release:
branches:
- master
types: [published]

jobs:
deploy:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*

0 comments on commit 74fa7b8

Please sign in to comment.