Skip to content

Commit

Permalink
Update GitHub workflow for pull requests gee-community#197
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Dec 8, 2020
1 parent 8e61381 commit 558cb5b
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 95 deletions.
78 changes: 39 additions & 39 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
on:
push:
branches:
- master
pull_request:
branches:
- master
push:
branches:
- master
# pull_request:
# branches:
# - master

name: build
jobs:
py-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.py }})
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, py: '3.7'}
- {os: macOS-latest, py: '3.7'}
- {os: ubuntu-latest, py: '3.6'}
- {os: ubuntu-latest, py: '3.7'}
- {os: ubuntu-latest, py: '3.8'}
py-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.py }})
strategy:
fail-fast: false
matrix:
config:
- { os: windows-latest, py: "3.7" }
- { os: macOS-latest, py: "3.7" }
- { os: ubuntu-latest, py: "3.6" }
- { os: ubuntu-latest, py: "3.7" }
- { os: ubuntu-latest, py: "3.8" }

env:
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
steps:
- name: CHECKOUT CODE
uses: actions/checkout@v2
- name: SETUP PYTHON
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.config.py }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --user --no-cache-dir Cython
pip install --user -r requirements.txt
pip install --user -r requirements_dev.txt
- name: LOAD EE CREDENTIALS
run: python ./.github/ee_token.py
env:
EARTHENGINE_TOKEN: ${{ secrets.EARTHENGINE_TOKEN }}
- name: GEEMAP-TEST
run: |
python -m unittest discover tests/
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
steps:
- name: CHECKOUT CODE
uses: actions/checkout@v2
- name: SETUP PYTHON
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.config.py }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --user --no-cache-dir Cython
pip install --user -r requirements.txt
pip install --user -r requirements_dev.txt
- name: LOAD EE CREDENTIALS
run: python ./.github/ee_token.py
env:
EARTHENGINE_TOKEN: ${{ secrets.EARTHENGINE_TOKEN }}
- name: GEEMAP-TEST
run: |
python -m unittest discover tests/
144 changes: 88 additions & 56 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,105 @@
# Run secret-dependent integration tests only after /ok-to-test approval
on:
pull_request:
repository_dispatch:
types: [ok-to-test-command]
pull_request:
repository_dispatch:
types: [ok-to-test-command]

name: Integration tests

jobs:
# Branch-based pull request
integration-trusted:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
# Branch-based pull request
integration-trusted:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Branch based PR checkout
uses: actions/checkout@v2

- name: Branch based PR checkout
uses: actions/checkout@v2
# <insert integration tests needing secrets>

# <insert integration tests needing secrets>
# Repo owner has commented /ok-to-test on a (fork-based) pull request
integration-fork:
runs-on: ubuntu-latest
if: github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.sha != '' &&
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.sha)
steps:
# Check out merge commit
- name: Fork based /ok-to-test checkout
uses: actions/checkout@v2
with:
ref: "refs/pull/${{ github.event.client_payload.pull_request.number }}/merge"

# Repo owner has commented /ok-to-test on a (fork-based) pull request
integration-fork:
runs-on: ubuntu-latest
if:
github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.sha != '' &&
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.sha)
steps:
# <insert integration tests needing secrets>

# Check out merge commit
- name: Fork based /ok-to-test checkout
uses: actions/checkout@v2
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
# runs-on: ${{ matrix.config.os }}
# name: ${{ matrix.config.os }} (${{ matrix.config.py }})
# strategy:
# fail-fast: false
# matrix:
# config:
# - { os: windows-latest, py: "3.7" }
# - { os: macOS-latest, py: "3.7" }
# - { os: ubuntu-latest, py: "3.6" }
# - { os: ubuntu-latest, py: "3.7" }
# - { os: ubuntu-latest, py: "3.8" }

# <insert integration tests needing secrets>
# env:
# SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
# steps:
# - name: CHECKOUT CODE
# uses: actions/checkout@v2
# - name: SETUP PYTHON
# uses: actions/setup-python@v1
# with:
# python-version: ${{ matrix.config.py }}
# - name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --user --no-cache-dir Cython
pip install --user -r requirements.txt
pip install --user -r requirements_dev.txt
- name: LOAD EE CREDENTIALS
run: python ./.github/ee_token.py
env:
EARTHENGINE_TOKEN: ${{ secrets.EARTHENGINE_TOKEN }}
- name: GEEMAP-TEST
run: |
python -m unittest discover tests/
- run: |
echo "Integration tests... success! ;-)"
- run: |
echo "Integration tests... success! ;-)"
# Update check run called "integration-fork"
- uses: actions/github-script@v1
id: update-check-run
if: ${{ always() }}
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
# Update check run called "integration-fork"
- uses: actions/github-script@v1
id: update-check-run
if: ${{ always() }}
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.checks.listForRef({
...context.repo,
ref
});
const { data: checks } = await github.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
const check = checks.check_runs.filter(c => c.name === process.env.job);
const { data: result } = await github.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
const { data: result } = await github.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;
return result;

0 comments on commit 558cb5b

Please sign in to comment.