Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reopening PR#5 #6

Open
wants to merge 85 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
eee414f
Update pip and "pip install" dependencies
lbianchi-lbl Nov 24, 2020
abc7e76
Add trigger and prelim. check to support running tests on PR approval
lbianchi-lbl Nov 24, 2020
137a479
Use one of the test matrix instances to generate coverage report
lbianchi-lbl Nov 24, 2020
326b24e
Remove branch name condition on PR trigger to make testing easier
lbianchi-lbl Nov 24, 2020
f6591eb
Add missing matrix context in if condition
lbianchi-lbl Nov 24, 2020
36adf52
Add more debug info to investigate false positive triggers
lbianchi-lbl Nov 24, 2020
56343bb
Display condition that should evaluate to false, but apparently doesn't
lbianchi-lbl Nov 24, 2020
04b46ec
Try with if condition explicitly set to literal false
lbianchi-lbl Nov 24, 2020
4848eaa
Try if explicit expression syntax is needed for composite if conditions
lbianchi-lbl Nov 24, 2020
3275ada
Another attempt since needs can interfere with job-level if
lbianchi-lbl Nov 24, 2020
325caa5
Try another attempt
lbianchi-lbl Nov 24, 2020
4b24173
One more attempt
lbianchi-lbl Nov 24, 2020
9698ecb
Try if the explicit comparison to true works
lbianchi-lbl Nov 24, 2020
7fc7398
Check if using fromJSON makes a difference
lbianchi-lbl Nov 24, 2020
5170596
Temporarily disable PR workflow trigger for debugging
lbianchi-lbl Nov 24, 2020
09a8cdb
Try with intermediate job with dependencies
lbianchi-lbl Nov 24, 2020
1453d19
Restore PR workflow trigger
lbianchi-lbl Nov 24, 2020
2460456
Address no steps defined error
lbianchi-lbl Nov 24, 2020
8cb2bca
Try using outputs in intermediate job
lbianchi-lbl Nov 24, 2020
db8bb68
Add syntax to evaluate expression in output
lbianchi-lbl Nov 24, 2020
d4256fb
Try comparing with string
lbianchi-lbl Nov 24, 2020
15b858a
Add debug info
lbianchi-lbl Nov 24, 2020
57d422c
Use toJSON() for display
lbianchi-lbl Nov 24, 2020
2625cc7
Try to see how needs output appears to following job
lbianchi-lbl Nov 24, 2020
bbac822
Move check to step in intermediate job
lbianchi-lbl Nov 24, 2020
7cb782c
Try if we can avoid having workflow status displayed as failure
lbianchi-lbl Nov 24, 2020
467d6c5
Revert to default to test if current version works for true positive
lbianchi-lbl Nov 24, 2020
c80207d
Add more debug output
lbianchi-lbl Nov 24, 2020
03e5228
Try to get to the bottom of true || false evaluating to false
lbianchi-lbl Nov 24, 2020
5afe1da
Commit to check if this triggers new reviews
lbianchi-lbl Nov 24, 2020
552d3d6
Try evaluating trigger check decision from action script
lbianchi-lbl Nov 24, 2020
c713043
Add missing single quotes
lbianchi-lbl Nov 24, 2020
c09cf83
Return script step result as string instead of JSON-encoded value
lbianchi-lbl Nov 24, 2020
af6bc7a
Improve debug info
lbianchi-lbl Nov 24, 2020
1340647
Extract pip install commands to env variables shared by all jobs
lbianchi-lbl Nov 24, 2020
3458aa5
Try trigger when idaes-build is requested as reviewer
lbianchi-lbl Nov 24, 2020
3f266c6
Rename and add logging for clarity
lbianchi-lbl Nov 25, 2020
212e53e
Use requested_reviewer field from event payload instead of PR object
lbianchi-lbl Nov 25, 2020
8402b2f
Use login field of reviewer directly
lbianchi-lbl Nov 25, 2020
cb5a85d
Try single file with workflow trigger dispatch and common setup action
lbianchi-lbl Nov 25, 2020
98e46d0
Remove spurious tick quote
lbianchi-lbl Nov 25, 2020
a4b1982
Fix issues with invalid action location and steps
lbianchi-lbl Nov 25, 2020
116f466
Quote pytest marker
lbianchi-lbl Nov 25, 2020
53ffb5e
Add back pull_request_review trigger
lbianchi-lbl Nov 25, 2020
22faef1
Use less ambiguous name and encode verdict enum as JSON in workflow env
lbianchi-lbl Nov 25, 2020
4118e1d
Store choices in decide job output since env is not available in job if
lbianchi-lbl Nov 25, 2020
59d2af7
Get to the bottom of whether fromJSON is needed or not
lbianchi-lbl Nov 25, 2020
b9b1224
Use fromJSON in if condition since it's required to get an object
lbianchi-lbl Nov 25, 2020
25815e4
Try "fail fast" approach based on job dependencies to check what to run
lbianchi-lbl Nov 25, 2020
2281a4c
Remove incomplete job definition
lbianchi-lbl Nov 25, 2020
e413089
Fix wrong name
lbianchi-lbl Nov 25, 2020
c31c7a6
Use strings instead of arrays in if to address unexpected symbol errors
lbianchi-lbl Nov 25, 2020
b38b7d5
Remove object literal in if condition
lbianchi-lbl Nov 25, 2020
e516664
Use context issue getter for guaranteed access to number property
lbianchi-lbl Nov 25, 2020
e8d574e
Try simpler approach with integration checks running on PR review only
lbianchi-lbl Nov 25, 2020
462f78d
Rename approval to review for workflow running PR integration tests
lbianchi-lbl Nov 25, 2020
aa86333
Add coverage report as separate job
lbianchi-lbl Nov 25, 2020
ac872c7
Add workflow for checks on main and other protected branches
lbianchi-lbl Nov 25, 2020
af016d1
Extract pylint and docs build steps to local actions
lbianchi-lbl Nov 25, 2020
e5dbf78
Add comments for info about workflow triggers
lbianchi-lbl Nov 25, 2020
f092f04
Add debug output
lbianchi-lbl Nov 25, 2020
943cfb6
Use correct name for requirements file
lbianchi-lbl Nov 25, 2020
f9262d8
Improve checks on submitted PR review for integration tests
lbianchi-lbl Nov 25, 2020
a92a819
Improve skip/run criteria and implementation
lbianchi-lbl Nov 25, 2020
7fa3173
Use correct schema for review event
lbianchi-lbl Nov 25, 2020
bc725f9
Move all jobs with checks under PR workflow for checks to show up in PR
lbianchi-lbl Nov 25, 2020
b785670
Split rapid/integration triggers to avoid shadowing running checks
lbianchi-lbl Nov 25, 2020
cde90b4
Try using label to trigger integration tests from PR review
lbianchi-lbl Nov 26, 2020
69b327f
Use API to fetch list of reviews for PR
lbianchi-lbl Nov 26, 2020
3c5b0ed
Merge two steps in one to get around limitations in data/state sharing
lbianchi-lbl Nov 26, 2020
1056b55
Convert functions in inline script to async
lbianchi-lbl Nov 26, 2020
fb6651c
Use await with async function
lbianchi-lbl Nov 26, 2020
7471a92
Refine algorithm for determining most recent review
lbianchi-lbl Nov 26, 2020
fe76b10
Add debug information for fetched reviews to detect pagination issues
lbianchi-lbl Nov 26, 2020
a87993c
Also run on review dismissal
lbianchi-lbl Nov 26, 2020
3149848
Fix wrong quote
lbianchi-lbl Nov 26, 2020
21e2ef8
Try pagination
lbianchi-lbl Nov 26, 2020
3a3586d
Try with async/await
lbianchi-lbl Nov 26, 2020
e0f407b
Try extracting trigger label name to workspace env context
lbianchi-lbl Nov 30, 2020
6cdf7d1
Add error handling for missing labels
lbianchi-lbl Nov 30, 2020
5e2d1d8
Improve debug display
lbianchi-lbl Nov 30, 2020
f9352d9
Move if check since env context is only supported for step-level if
lbianchi-lbl Nov 30, 2020
24ff1ed
Move back check for label name since it must be done at the job level
lbianchi-lbl Nov 30, 2020
35071bf
Fix minor typo
lbianchi-lbl Nov 30, 2020
0b215ef
Try more restrictive check for labeled event
lbianchi-lbl Nov 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Build Sphinx docs
description: Requires the setup-idaes action to be run before this
# TODO add options as inputs as needed
runs:
using: "composite"
steps:
- name: Build Sphinx docs (HTML)
shell: bash
run: |
cd docs/
python build.py
19 changes: 19 additions & 0 deletions .github/actions/pylint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run pylint
description: Run static analysis using pylint
# TODO add inputs (options) as needed
runs:
using: "composite"
steps:
- name: Install pylint dependencies
shell: bash
run: |
PIP_INSTALL="pip --no-cache-dir install --progress-bar off"
$PIP_INSTALL --upgrade pip setuptools wheel
# TODO the pylint version will have to be pinned
# TODO installing idaes is necessary in our case because we import some idaes code in pylint plugins
$PIP_INSTALL pylint -r requirements.txt
# don't think we need to install the extensions, though
- name: Run pylint (errors only)
shell: bash
run: |
pylint -E --ignore-patterns="test_.*" idaes || true
36 changes: 36 additions & 0 deletions .github/actions/setup-idaes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Setup IDAES
description: Install IDAES and extensions
inputs:
install-target:
description: 'Command-line arguments and options to pass to the install command, e.g. pip install'
required: true
install-command:
description: 'Command to use to install `install-target`'
required: false
default: pip --no-cache-dir install --progress-bar off
runs:
using: "composite"
steps:
- name: Update pip and other packaging tools
shell: bash
run: |
${{ inputs.install-command }} pip setuptools wheel
- name: Install idaes and dependencies
shell: bash
run: |
${{ inputs.install-command }} ${{ inputs.install-target}}
idaes --version
- name: Install extensions
shell: bash
run: |
idaes get-extensions --verbose
# add bin directory to $PATH (only valid for subsequent steps)
echo "$(idaes bin-directory)" >> $GITHUB_PATH
- name: Test access to executables
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
ipopt.exe -v
else
ipopt -v
fi
32 changes: 32 additions & 0 deletions .github/scripts/countApproved.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const REVIEW_STATE = {
dismissed: "DISMISSED",
approved: "APPROVED",
};

function selectLatestPerUser(reviews) {
const latestByUser = {};
reviews.forEach((r) => {
// the reviews are in chronological order (earliest to latest)
// so to get the latest for each user we can use an Object as a map and loop over all reviews
// at each iteration, a more recent review for that user will replace an earlier one set before it
latestByUser[r.user.login] = r;
});
return Object.values(latestByUser);
}

module.exports = async ({ github, owner, repo, pullNumber }) => {
const { data: reviews } = await github.pulls.listReviews({
owner: owner,
repo: repo,
pull_number: pullNumber,
});

const latestReviews = selectLatestPerUser(reviews);
console.log(latestReviews);
const countApproved = latestReviews.filter(
(r) => r.state === REVIEW_STATE.approved
).length;
console.log(`${countApproved} approving reviews`);

return countApproved;
};
68 changes: 0 additions & 68 deletions .github/workflows/integration-tests.yml

This file was deleted.

102 changes: 102 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Main

on:
push:
branches:
# TODO this could also be run when pushing to main, but could end up clogging the CI when merging multiple PRs
- rel_*
schedule:
# run daily at 5:00 am UTC (12 am ET/9 pm PT)
- cron: '0 5 * * *'
repository_dispatch:
# to run this, send a POST API call at repos/IDAES/idaes-pse/dispatches with the specified event_type
# e.g. `gh repos/IDAES/idaes-pse/dispatches -F event_type=run_tests`
types: [run_tests]
workflow_dispatch:
inputs:
git-ref:
description: Git hash (optional)
required: false

jobs:
pytest:
name: All tests (py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- '3.6'
- '3.7'
os:
- ubuntu-18.04
- windows-latest
steps:
- name: Display debug info
run: |
echo '${{ toJSON(matrix) }}'
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up idaes
uses: ./.github/actions/setup-idaes
with:
install-target: '.'
- name: Run pytest (all)
run: |
pytest
build-docs:
name: Build Sphinx docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Set up idaes
uses: ./.github/actions/setup-idaes
with:
install-target: -r requirements-dev.txt
- name: Build Sphinx docs
uses: ./.github/actions/build-docs
- name: Publish built docs
uses: actions/upload-artifact@v2
with:
name: idaes-pse-docs-html
path: docs/build/html/
retention-days: 7
pylint:
name: pylint (errors only)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Run pylint
uses: ./.github/actions/pylint
pytest-coverage:
name: Run pytest with coverage report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Set up idaes
uses: ./.github/actions/setup-idaes
with:
install-target: -r requirements-dev.txt
- name: Run pytest with cov
run: |
pytest --cov
- name: Upload coverage report to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
bash <(curl -s https://codecov.io/bash)
68 changes: 68 additions & 0 deletions .github/workflows/pr-approved.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: PR (integration)

on:
pull_request:
types: [labeled]

env:
PR_APPROVED_LABEL_NAME: 'ci:approved'

jobs:
check-skip:
name: check if integration tests should run
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, env.PR_APPROVED_LABEL_NAME)
steps:
- name: notify
run: echo "The integration tests will run"
pytest:
name: Integration tests (py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [check-skip]
strategy:
fail-fast: false
matrix:
python-version:
- '3.6'
- '3.7'
os:
- ubuntu-18.04
- windows-latest
steps:
- name: Display debug info
run: |
echo '${{ toJSON(matrix) }}'
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up idaes
uses: ./.github/actions/setup-idaes
with:
install-target: '.'
- name: Run pytest (not integration)
run: |
pytest -m 'integration'
pytest-coverage:
name: Run pytest (complete) with coverage report
runs-on: ubuntu-latest
needs: [check-skip]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Set up idaes
uses: ./.github/actions/setup-idaes
with:
install-target: -r requirements-dev.txt
- name: Run pytest (complete) with cov
run: |
pytest --cov
- name: Upload coverage report to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
bash <(curl -s https://codecov.io/bash)
Loading