Skip to content

Commit

Permalink
Fix CI handling of API key
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Dec 30, 2024
1 parent ae5d6f8 commit f0ad96f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ jobs:
- name: Run Tests
env:
TEST_TYPE: ${{ matrix.type }}
GITHUB_ETHERSCAN: ${{ secrets.GITHUB_ETHERSCAN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ jobs:
solc-select use latest --always-install
- name: Run Tests
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
run: |
pytest tests
40 changes: 13 additions & 27 deletions scripts/ci_test_etherscan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ cd "$DIR" || exit 255

solc-select use 0.4.25 --always-install

delay_etherscan () {
# Perform a small sleep when API key is not available (e.g. on PR CI from external contributor)
if [ "$GITHUB_ETHERSCAN" = "" ]; then
sleep 5s
else
# Always sleep 2 second in the CI
# We have a lot of concurrent github action so this is needed
sleep 2s
fi
}
# Etherscan now _requires_ an API key, so skip the tests if it's not available
if [ "$ETHERSCAN_API_KEY" = "" ]; then
echo "API key not available, skipping etherscan tests"
exit 0
fi

echo "::group::Etherscan mainnet"
crytic-compile 0x7F37f78cBD74481E593F9C737776F7113d76B315 --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
crytic-compile 0x7F37f78cBD74481E593F9C737776F7113d76B315 --compile-remove-metadata --etherscan-apikey "$ETHERSCAN_API_KEY"

if [ $? -ne 0 ]
then
Expand All @@ -28,11 +23,10 @@ then
fi
echo "::endgroup::"

delay_etherscan

# From crytic/slither#1154
# Try without an explicit API key argument, to verify reading `ETHERSCAN_API_KEY` from env works fine
echo "::group::Etherscan #3"
crytic-compile 0xcfc1E0968CA08aEe88CbF664D4A1f8B881d90f37 --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
crytic-compile 0xcfc1E0968CA08aEe88CbF664D4A1f8B881d90f37 --compile-remove-metadata

if [ $? -ne 0 ]
then
Expand All @@ -41,11 +35,9 @@ then
fi
echo "::endgroup::"

delay_etherscan

# From crytic/crytic-compile#415
echo "::group::Etherscan #4"
crytic-compile 0x19c7d0fbf906c282dedb5543d098f43dfe9f856f --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
crytic-compile 0x19c7d0fbf906c282dedb5543d098f43dfe9f856f --compile-remove-metadata --etherscan-apikey "$ETHERSCAN_API_KEY"

if [ $? -ne 0 ]
then
Expand All @@ -54,11 +46,9 @@ then
fi
echo "::endgroup::"

delay_etherscan

# From crytic/crytic-compile#150
echo "::group::Etherscan #5"
crytic-compile 0x2a311e451491091d2a1d3c43f4f5744bdb4e773a --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
crytic-compile 0x2a311e451491091d2a1d3c43f4f5744bdb4e773a --compile-remove-metadata --etherscan-apikey "$ETHERSCAN_API_KEY"

if [ $? -ne 0 ]
then
Expand All @@ -74,11 +64,9 @@ then
fi
echo "::endgroup::"

delay_etherscan

# From crytic/crytic-compile#151
echo "::group::Etherscan #6"
crytic-compile 0x4c808e3c011514d5016536af11218eec537eb6f5 --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
crytic-compile 0x4c808e3c011514d5016536af11218eec537eb6f5 --compile-remove-metadata --etherscan-apikey "$ETHERSCAN_API_KEY"

if [ $? -ne 0 ]
then
Expand All @@ -87,11 +75,9 @@ then
fi
echo "::endgroup::"

delay_etherscan

# via-ir test for crytic/crytic-compile#517
echo "::group::Etherscan #7"
crytic-compile 0x9AB6b21cDF116f611110b048987E58894786C244 --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
crytic-compile 0x9AB6b21cDF116f611110b048987E58894786C244 --compile-remove-metadata --etherscan-apikey "$ETHERSCAN_API_KEY"

if [ $? -ne 0 ]
then
Expand All @@ -102,7 +88,7 @@ echo "::endgroup::"

# From crytic/crytic-compile#544
echo "::group::Etherscan #8"
crytic-compile 0x9AB6b21cDF116f611110b048987E58894786C244 --etherscan-apikey "$GITHUB_ETHERSCAN"
crytic-compile 0x9AB6b21cDF116f611110b048987E58894786C244 --etherscan-apikey "$ETHERSCAN_API_KEY"

if [ $? -ne 0 ]
then
Expand Down
Loading

0 comments on commit f0ad96f

Please sign in to comment.