Skip to content

Commit

Permalink
Merge pull request #142 from DanielSchiavini/pipeline
Browse files Browse the repository at this point in the history
ci: Use `pull_request_target` with permissions check
  • Loading branch information
charles-cooper authored Feb 14, 2024
2 parents 6117f96 + 1feede1 commit 6fe4fa6
Showing 1 changed file with 44 additions and 15 deletions.
59 changes: 44 additions & 15 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: unitary

on: [ "push", "pull_request" ]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on:
pull_request_target:
push:
branches:
- master

jobs:
unitary:
Expand All @@ -15,10 +16,10 @@ jobs:
name: "unit tests: python ${{ matrix.python-version }}"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
Expand All @@ -44,15 +45,14 @@ jobs:
--cov-fail-under=70
tests/unitary/
integration:
name: "integration tests (forked and networked modes)"
anvil:
name: "integration tests (anvil)"
runs-on: ubuntu-latest
# only run in single process, so there is no contention for sepolia tx nonce
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Python 3.11
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
Expand All @@ -65,16 +65,45 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Networked Tests against anvil
# run separately to clarify its dependency on outside binary
run: pytest -n auto tests/integration/network/anvil/

integration:
name: "integration tests (Alchemy: fork mode and Sepolia)"
runs-on: ubuntu-latest
steps:
- name: Check if the user is a contributor
uses: actions/github-script@v7
with:
script: |
const { actor: username, repo: { owner, repo } } = context;
const collaborator = await github.rest.repos.getCollaboratorPermissionLevel({ owner, repo, username });
if (!collaborator.data.user.permissions.push) {
core.setFailed(username + ' is not a contributor');
}
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"

- name: Install Requirements
run: |
pip install -r dev-requirements.txt
pip install .
- name: Run Fork Mode Tests
run: pytest -n auto tests/integration/fork/
env:
MAINNET_ENDPOINT: ${{ secrets.ALCHEMY_MAINNET_ENDPOINT }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}

- name: Run Networked Tests against anvil
# run separately to clarify its dependency on outside binary
run: pytest -n auto tests/integration/network/anvil/

- name: Run Sepolia Tests
# disable xdist, otherwise they can contend for tx nonce
run: pytest -n 0 tests/integration/network/sepolia/
Expand Down

0 comments on commit 6fe4fa6

Please sign in to comment.