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

Coverage action #856

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
778b255
file name test
aGuttman Jun 5, 2022
ae58964
dir name test
aGuttman Jun 5, 2022
d586add
Create test-default-action.yml
aGuttman Jun 5, 2022
beed818
test coverage badge
aGuttman Jun 5, 2022
fee792e
Update test-default-action.yml
aGuttman Jun 5, 2022
6c13ec5
Update .coverage
aGuttman Jun 5, 2022
de28ce7
Update test-default-action.yml
aGuttman Jun 5, 2022
4732c8a
Update test-default-action.yml
aGuttman Jun 5, 2022
6e49c6a
Create .coveragerc
aGuttman Jun 5, 2022
29d13c8
Update .coveragerc
aGuttman Jun 5, 2022
0cd8eaf
Update .coverage
aGuttman Jun 5, 2022
28b125e
Update test-default-action.yml
aGuttman Jun 5, 2022
d870820
Update test-default-action.yml
aGuttman Jun 5, 2022
5cc18f8
Updated coverage.svg
github-actions[bot] Jun 5, 2022
1e31ec5
Update README.md
aGuttman Jun 5, 2022
d78dcc4
Update test-default-action.yml
aGuttman Jun 5, 2022
8010e54
Update .coverage
aGuttman Jun 5, 2022
a374d38
Updated coverage.svg
github-actions[bot] Jun 5, 2022
1ab4520
Update test-default-action.yml
aGuttman Jun 5, 2022
4125535
Merge branch 'coverage_action' of https://github.com/aGuttman/e-missi…
aGuttman Jun 5, 2022
e00efa1
Updated coverage.svg
github-actions[bot] Jun 5, 2022
3c20586
revert file names
aGuttman Jun 5, 2022
bfd4e4a
revert file names
aGuttman Jun 5, 2022
536fa8d
Update .gitignore
aGuttman Jun 5, 2022
e882944
Merge branch 'e-mission:master' into coverage_action
aGuttman Jun 6, 2022
a9a279d
Update coverage-badge-and-comment.yml
aGuttman Jun 6, 2022
76345e7
Create coverage.yml
aGuttman Jun 6, 2022
0866d6a
add coverage action to gis branch, set verbose option comment action
aGuttman Jun 6, 2022
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
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
relative_files = True
omit =
*tests*
*bottle.py
109 changes: 109 additions & 0 deletions .github/workflows/coverage-badge-and-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# This is a basic workflow to help you get started with Actions

name: Coverage

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master, gis-based-mode-detection ]
pull_request:
branches: [ master, gis-based-mode-detection ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Install and start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 4.4.0

- name: Check existing version of miniconda
shell: bash -l {0}
run: conda info -a

- name: Install miniconda
shell: bash -l {0}
run: |
source setup/setup_conda.sh Linux-x86_64

- name: Check whether the CI environment variable is set
shell: bash -l {0}
run: |
source setup/activate_conda.sh
echo $CI

- name: Setup the emission environment for testing
shell: bash -l {0}
run: |
conda --version
which conda
source setup/activate_conda.sh
conda --version
source setup/setup.sh
conda env list

- name: Switch to emission, install/run Coverage
shell: bash -l {0}
run: |
conda env list
source setup/activate.sh
conda env list
pip install coverage
coverage --version
export PYTHONPATH=.
coverage run -m unittest discover -s emission/tests -p Test*;
coverage report

- name: Coverage Badge
uses: tj-actions/[email protected]

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v9
id: changed_files
with:
files: coverage.svg

- name: Commit files
if: steps.changed_files.outputs.files_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add coverage.svg
git commit -m "Updated coverage.svg"

- name: Push changes
if: steps.changed_files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.github_token }}
branch: ${{ github.head_ref }}
aGuttman marked this conversation as resolved.
Show resolved Hide resolved

- name: Coverage comment
id: coverage_comment
uses: ewjoachim/python-coverage-comment-action@v2
with:
GITHUB_TOKEN: ${{ github.token }}
VERBOSE: true

- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v2
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly
name: python-coverage-comment-action
# If you use a different name, update COMMENT_FILENAME accordingly
path: python-coverage-comment-action.txt

- name: Teardown the test environment
shell: bash -l {0}
run: source setup/teardown_tests.sh
25 changes: 25 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Post coverage comment

on:
workflow_run:
workflows: ["Coverage"]
types:
- completed

jobs:
test:
name: Run tests & display coverage
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
steps:
# DO NOT run actions/checkout@v2 here, for securitity reasons
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- name: Post comment
uses: ewjoachim/python-coverage-comment-action@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}
VERBOSE: true
# Update those if you changed the default values:
# COMMENT_ARTIFACT_NAME: python-coverage-comment-action
# COMMENT_FILENAME: python-coverage-comment-action.txt
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ conf/**/*.json
*.ipynb_checkpoints*

*.secret

.coverage
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ backend server - the phone apps are available in the [e-mission-phone
repo](https://github.com/amplab/e-mission-phone)


- **Master** [![master:test-with-docker](https://github.com/e-mission/e-mission-server/workflows/test-with-docker/badge.svg)](https://github.com/e-mission/e-mission-server/actions?query=branch%3Amaster+workflow%3Atest-with-docker) [![master:ubuntu-only-test-with-manual-install](https://github.com/e-mission/e-mission-server/workflows/ubuntu-only-test-with-manual-install/badge.svg)](https://github.com/e-mission/e-mission-server/actions?query=branch%3Amaster+workflow%3Aubuntu-only-test-with-manual-install) [![master:osx-ubuntu-manual-install](https://github.com/e-mission/e-mission-server/workflows/osx-ubuntu-manual-install/badge.svg)](https://github.com/e-mission/e-mission-server/actions?query=branch%3Amaster+workflow%3Aosx-ubuntu-manual-install)
- **Master** [![master:test-with-docker](https://github.com/e-mission/e-mission-server/workflows/test-with-docker/badge.svg)](https://github.com/e-mission/e-mission-server/actions?query=branch%3Amaster+workflow%3Atest-with-docker) [![master:ubuntu-only-test-with-manual-install](https://github.com/e-mission/e-mission-server/workflows/ubuntu-only-test-with-manual-install/badge.svg)](https://github.com/e-mission/e-mission-server/actions?query=branch%3Amaster+workflow%3Aubuntu-only-test-with-manual-install) [![master:osx-ubuntu-manual-install](https://github.com/e-mission/e-mission-server/workflows/osx-ubuntu-manual-install/badge.svg)](https://github.com/e-mission/e-mission-server/actions?query=branch%3Amaster+workflow%3Aosx-ubuntu-manual-install) ![coverage badge](./coverage.svg)

- **GIS branch:** [![master:ubuntu-only-test-with-manual-install](https://github.com/e-mission/e-mission-server/workflows/ubuntu-only-test-with-manual-install/badge.svg?branch=gis-based-mode-detection)](https://github.com/e-mission/e-mission-server/actions?query=branch%3Agis-based-mode-detection+workflow%3Aubuntu-only-test-with-manual-install) [![osx-ubuntu-manual-install](https://github.com/e-mission/e-mission-server/workflows/osx-ubuntu-manual-install/badge.svg?branch=gis-based-mode-detection)](https://github.com/e-mission/e-mission-server/actions?query=branch%3Agis-based-mode-detection+workflow%3Aosx-ubuntu-manual-install)

Expand Down
21 changes: 21 additions & 0 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.