-
Notifications
You must be signed in to change notification settings - Fork 0
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
Python Measure Unit Test Action #19
Open
jslane-h
wants to merge
37
commits into
master
Choose a base branch
from
unit_test_action
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 20 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
9e7aee7
Add python unit tests job
jslane-h d224b15
Fix deprecated command
jslane-h d92b6b0
Update python_measure_dirs format
jslane-h 07fa9d3
Add copper dependency
jslane-h e26c295
Fix measure import
jslane-h 93b3843
Add constrain import
jslane-h e8acb50
Update test_file path
jslane-h 3fd135c
Remove pythonpath var
jslane-h b92ceb9
WIP: Add measure check
jslane-h 9e59393
Install openstudio cli in action
jslane-h 12b0819
Test to see if able to build container with openstudio
jslane-h ffcaf53
Update dockerfile
jslane-h 41e3934
Fix dockerfile
jslane-h dfe1e65
Update build docker image step
jslane-h 342487b
Update action
jslane-h 3bb2fd3
Update action
jslane-h d53eca0
Test action
jslane-h ee83fc4
Update action
jslane-h c5e0cad
Debug action
jslane-h cc58c0a
Test action
jslane-h 30bc55b
Test storing test results in github workspace due to file permissions
jslane-h d11abaa
Use github workspace as working directory
jslane-h e21faab
Change github workspace var
jslane-h 3e03ddb
Update github workspace var
jslane-h 4fe2f52
try checkout v4
jslane-h 6ea224d
move Dockerfile to actions folder
jslane-h 7bec849
debug
jslane-h 5ec527f
debug
jslane-h 8dffb8d
Create action yaml
jslane-h 8e0cd62
test
jslane-h 9e4f096
Use $GITHUB_WORKSPACE in container
jslane-h 9bab626
Add entrypoint file
jslane-h 52678b0
Fix entrypoint
jslane-h ab27c8a
Fix entrypoint script
jslane-h b9cd8bb
Output to test_results folder (it is finally working)
jslane-h 6380b54
Test update measure xml's
jslane-h 2ab05ea
Auto-update measure.xml files by GitHub Actions
actions-user File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
on: | ||
push: | ||
branches: [ '*' ] | ||
|
||
jobs: | ||
run-python-unit-tests: | ||
name: Run python unit tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t python_measure_test . | ||
docker run --rm \ | ||
-v ${{ github.workspace }}/test_results:/app/test_results \ | ||
python_measure_test | ||
|
||
- name: Check for FAILURE in pytest_output.txt | ||
run: | | ||
ls test_results | ||
# cat test_results/pytest_output.txt | ||
# if grep -q 'FAILURE' test_results/pytest_output.txt; then | ||
# exit 1 | ||
# fi | ||
|
||
- name: Upload Test Results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test_results | ||
path: test_results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Start with the OpenStudio image | ||
FROM python:3.10 | ||
|
||
RUN wget https://github.com/NREL/OpenStudio/releases/download/v3.9.0/OpenStudio-3.9.0+c77fbb9569-Ubuntu-22.04-x86_64.tar.gz && \ | ||
tar -xvzf OpenStudio-3.9.0+c77fbb9569-Ubuntu-22.04-x86_64.tar.gz && \ | ||
cp -r OpenStudio-3.9.0+c77fbb9569-Ubuntu-22.04-x86_64/usr/local/openstudio-3.9.0 /usr/local/openstudio | ||
|
||
ENV PATH="/usr/local/openstudio/bin:${PATH}" | ||
|
||
# Set Python 3 as the default Python | ||
RUN ln -s /usr/bin/python3 /usr/bin/python | ||
|
||
# Install Python dependencies | ||
RUN pip install --no-cache-dir pytest openstudio copper-bem constrain | ||
|
||
# Set the working directory within the container | ||
WORKDIR /app | ||
|
||
# Copy the current directory contents into the container | ||
COPY . /app | ||
|
||
# Find directories containing measure.py and run tests | ||
RUN bash -c "\ | ||
mkdir test_results && \ | ||
openstudio measure -t ./lib/measures > test_results/measure_check_output.txt && \ | ||
for dir in \$(find . -type f -name 'measure.py' -exec dirname {} \; | sort -u); do \ | ||
pytest \$dir >> test_results/pytest_output.txt; \ | ||
done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
|
||
# Find directories containing measure.py | ||
dirs = set(os.path.dirname(root) for root, _, files in os.walk('.') if 'measure.py' in files) | ||
|
||
# Write directories to a file and run tests | ||
with open('/app/python_measure_dirs.txt', 'w') as f: | ||
for dir in dirs: | ||
f.write(dir + '\n') | ||
os.system(f'openstudio measure -t {dir} > {dir}/measure_check_output.txt') | ||
os.system(f'pytest {dir} > {dir}/pytest_output.txt') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weilixu - should we always test using the latest version of OpenStudio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure - I guess it should depends on the measure dependency. If all measures move at the same pace, we can use the latest OS version for testing.