Skip to content

Commit

Permalink
Another approach for only triggering the big jobs when there were cha…
Browse files Browse the repository at this point in the history
…nges in the last 24 hours (#668)
  • Loading branch information
tzaffi committed Feb 15, 2023
1 parent 33d79f4 commit d8f8dec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python }}"
- name: Test Python version
Expand All @@ -55,7 +55,7 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python }}"
- name: Install python dependencies
Expand Down
66 changes: 18 additions & 48 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,8 @@ on:
- cron: "10 * * * *"

jobs:
check-date:
runs-on: ubuntu-20.04
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@v2

- name: Current Boston time
run: TZ='America/New_York' && export TZ && date +"%A, %B %d, %Y %I:%M:%S %p %Z"

- name: print latest_commit
run: echo ${{ github.sha }}

- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z "$(git rev-list --after='24 hours' ${{ github.sha }})" && echo "::set-output name=should_run::false"

build-test:
needs: [check-date]
if: ${{ github.event_name == 'release' || needs.check_date.outputs.should_run == 'true' }}

nightly-slow-unit-tests:
name: build-test + nightly-slow if changes in the previous 24 hours
runs-on: ubuntu-20.04
container: python:${{ matrix.python }}
strategy:
Expand All @@ -39,13 +17,18 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check for code changes
id: check
run: make check-code-changes
- name: Install Python dependencies, Build, and Test
if: ${{ env.should_run == 'true' }}
run: make setup-build-test
- name: Super slow unit tests
if: ${{ env.should_run == 'true' }}
run: make nightly-slow

run-integration-tests:
needs: [check-date]
if: ${{ github.event_name == 'release' || needs.check_date.outputs.should_run == 'true' }}

nightly-run-integration-tests:
name: run-integration-tests if changes in the previous 24 hours
runs-on: ubuntu-20.04
strategy:
matrix:
Expand All @@ -55,33 +38,20 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v3
- name: Check for code changes
id: check
run: make check-code-changes
- uses: actions/setup-python@v4
if: ${{ env.should_run == 'true' }}
with:
python-version: "${{ matrix.python }}"
- name: Test Python version
if: ${{ env.should_run == 'true' }}
run: |
installed="$(python --version)"
expected="${{ matrix.python }}"
echo $installed
[[ $installed =~ "Python ${expected}" ]] && echo "Configured Python" || (echo "Failed to configure Python" && exit 1)
- name: Integration tests using algod
if: ${{ env.should_run == 'true' }}
run: make algod-integration

nighly-slow:
needs: [check-date]
if: ${{ github.event_name == 'release' || needs.check_date.outputs.should_run == 'true' }}

runs-on: ubuntu-20.04
strategy:
matrix:
python: ["3.10", "3.11"]
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v3
with:
python-version: "${{ matrix.python }}"
- name: Insert slow tests here
run: make nighly-slow
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ setup-build-test: setup-development lint-and-test

algod-integration: algod-start setup-development test-integration algod-stop

check-code-changes:
git config --global --add safe.directory /__w/pyteal/pyteal
[ -n "$$(git log --since='24 hours ago')" ] && (echo "should_run=true" >> $(GITHUB_ENV)) || (echo "should_run=false" >> $(GITHUB_ENV))

nightly-slow:
echo "TODO - this is a stub for a very slow test"

Expand Down

0 comments on commit d8f8dec

Please sign in to comment.