-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from ZedThree/tests
Add some basic tests; refactor project layout
- Loading branch information
Showing
19 changed files
with
809 additions
and
159 deletions.
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
**/venv | ||
**/__pycache__ | ||
.git |
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,26 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.py' | ||
pull_request: | ||
paths: | ||
- '**.py' | ||
|
||
jobs: | ||
pytest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install post/clang_tidy_review[tests] | ||
- name: Test with pytest | ||
run: "pytest -v" |
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
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 |
---|---|---|
|
@@ -267,8 +267,44 @@ jobs: | |
- uses: ZedThree/clang-tidy-review/[email protected] | ||
``` | ||
|
||
The lint workflow runs with limited permissions, while the post comments workflow has the required permissions because it's triggered by the `workflow_run` event. | ||
Read more about workflow security limitations [here](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/). | ||
The lint workflow runs with limited permissions, while the post | ||
comments workflow has the required permissions because it's triggered | ||
by the `workflow_run` event. | ||
|
||
Read more about workflow security limitations | ||
[here](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/). | ||
|
||
## Project layout | ||
|
||
This project is laid out as follows: | ||
|
||
``` | ||
. | ||
├── action.yml # The `review` Action | ||
├── Dockerfile | ||
└── post | ||
├── action.yml # The `post` Action | ||
├── Dockerfile | ||
└── clang_tidy_review # Common python package | ||
└── clang_tidy_review | ||
├── __init__.py | ||
├── post.py # Entry point for `post` | ||
└── review.py # Entry point for `review` | ||
``` | ||
|
||
In order to accommodate the split workflow, the `review` and `post` | ||
actions must have their own Action metadata files. GitHub requires | ||
this file to be named exactly `action.yml`, so they have to be in | ||
separate directories. The associated `Dockerfile`s must also be named | ||
exactly `Dockerfile`, so they also have to be separate directories. | ||
|
||
Lastly, we want to be able to reuse the python package between the two | ||
Actions, which means it must be in a subdirectory of _both_ | ||
`Dockerfile`s because they can't see parent directories. | ||
|
||
Which is why we've ended up with this slightly strange structure! This | ||
way, we can `COPY` the python package into both Docker images. | ||
|
||
|
||
## Real world project samples | ||
|Project|Workflow| | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,8 @@ | ||
FROM python:3 | ||
|
||
COPY requirements.txt /requirements.txt | ||
COPY clang_tidy_review /clang_tidy_review | ||
|
||
RUN pip3 install --upgrade pip && \ | ||
pip3 install -r requirements.txt | ||
pip3 install /clang_tidy_review | ||
|
||
WORKDIR /action | ||
|
||
COPY post.py /action/post.py | ||
COPY clang_tidy_review /action/clang_tidy_review | ||
|
||
ENTRYPOINT ["/action/post.py"] | ||
ENTRYPOINT ["post"] |
Empty file.
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
Oops, something went wrong.