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

Try a reusable workflow for pull requests #1

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
94549c7
Try a reusable workflow for pull requests
Jul 26, 2022
ee8fb6e
Check out repository before referring to files
Jul 26, 2022
7c9f9fd
The file extension seems unnecessary
Jul 26, 2022
2b57d4e
List files in the workflows directory
Jul 26, 2022
819a80c
Try the local directory
Jul 26, 2022
f0870ad
Maybe you need to refer to the job?
Jul 26, 2022
254c1c7
Stop running actions-demo on push for now
Jul 26, 2022
e2ee499
actions-demo is not available on main
Jul 26, 2022
acf86f1
Put the reuse on the steps level
Jul 26, 2022
f746fef
Cannot specify version when calling local workflows
Jul 26, 2022
befa8df
Do we need the whole preamble then?
Jul 26, 2022
e872481
Maybe not even runs-on?
Jul 26, 2022
5b4ec6f
Break some tests
Jul 26, 2022
1184ce3
Publish testresults.xml
Jul 26, 2022
e6d71b3
Add more tests
Jul 26, 2022
f5b8445
Remove invalid step
Jul 26, 2022
6d89117
Run pep8 and pylint before pytest
Jul 26, 2022
b7004a4
Refer to module instead of filename for coverage
Jul 26, 2022
513eefc
Update artifact filename
Jul 26, 2022
375247c
Get rid of line-too-long errors
Jul 26, 2022
ce39e50
Remove extra whitespace because pep8 asks so nicely
Jul 26, 2022
d1e2d36
pep8 is now pycodestyle
Jul 26, 2022
8b0760a
Pycodestyle should be happy now
Jul 26, 2022
ac16937
Some extra jobs
Jul 27, 2022
630431e
Runs on
Jul 27, 2022
b3729c1
Introduce workflow dependencies and sleeps
Venefyxatu Jul 27, 2022
27741dd
Ignore failing tests for a moment
Jul 27, 2022
6ddd8ad
Stop ignoring test failures and sleeping
Jul 27, 2022
c594eef
Try using a marketplace action
Venefyxatu Jul 27, 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
23 changes: 20 additions & 3 deletions .github/workflows/actions-demo.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Github Actions demo
on:
push:
workflow_call:
# push:

jobs:
Demo-github-actions:
runs-on: ubuntu-latest
Expand All @@ -16,11 +17,27 @@ jobs:
- run: echo "Job status is ${{ job.status }}"
- name: Install virtualenv
run: |
pip3 install --upgrade pip
pip3 install virtualenv
- name: Set up virtualenv
run: |
virtualenv --python=python3 venv
venv/bin/pip install -r requirements.txt
- name: Run tests
- name: Run pycodestyle
run: |
venv/bin/pytest --junit-xml=testresults.xml test.py
venv/bin/pycodestyle --max-line-length=120 main.py
- name: Run pylint
run: |
venv/bin/pylint --max-line-length=120 main.py
continue-on-error: true
- name: Run pytest
run: |
venv/bin/pytest --junit-xml=testresults.xml --cov=main --cov-report=html --cov-fail-under=90 test.py
- name: Upload testresults and coverage
uses: actions/upload-artifact@v3
with:
name: testresults
path: |
testresults.xml
htmlcov
if: ${{ always() }}
29 changes: 29 additions & 0 deletions .github/workflows/merge-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Merge Demo
on:
pull_request:

jobs:
use-action:
runs-on: Ubuntu-latest
steps:
- name: First interaction
uses: actions/[email protected]
with:
# Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }}
repo-token: "{{ secrets.GITHUB_TOKEN }}"
# Comment to post on an individual's first issue
issue-message: "Welcome to the project!"
# Comment to post on an individual's first pull request
pr-message: "Thank you for your PR!"
actual-reuse:
uses: ./.github/workflows/actions-demo.yml
report-status:
runs-on: ubuntu-latest
needs: actual-reuse
steps:
- run: echo "Job status is ${{ job.status }}"
report-revision:
runs-on: ubuntu-latest
needs: report-status
steps:
- run: echo "Running from branch ${{ github.ref }} in repository ${{ github.repository }}"
13 changes: 8 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def get_parallel_limits(holding_radial, turn):

direct_radial = get_reciprocal(direct_reciprocal)


return direct_radial, direct_reciprocal


Expand All @@ -52,7 +51,8 @@ def is_clockwise_between(radial_a, radial_b, course):

if radial_a < radial_b and reciprocal_course in range(radial_a, radial_b + 1):
return True
elif radial_a > radial_b and (reciprocal_course in range(radial_a, 360 + 1) or reciprocal_course in range(1, radial_b + 1)):
elif radial_a > radial_b and (reciprocal_course in range(radial_a, 360 + 1) or
reciprocal_course in range(1, radial_b + 1)):
return True
else:
return False
Expand All @@ -78,7 +78,8 @@ def get_entry(holding_radial, turn, direct_radial, direct_reciprocal, inbound_co
else:
return Entries.TEARDROP
else:
raise ValueError(f'Unhandled edge case: {holding_radial}, {turn.value}, {direct_radial}, {direct_reciprocal}, {inbound_course}')
raise ValueError(f'''Unhandled edge case: {holding_radial}, {turn.value}, {direct_radial}, '''
f'''{direct_reciprocal}, {inbound_course}''')


def quiz(args):
Expand All @@ -99,7 +100,8 @@ def quiz(args):
answer = None
while answer not in [e.value for e in Entries]:
print(80 * '-')
print(f'Choose entry method for holding on radial {holding_radial} with {turn.value} turn and arriving on course {inbound_course}.')
print(f'''Choose entry method for holding on radial {holding_radial} with {turn.value} turn '''
f'''and arriving on course {inbound_course}.''')
for entry in Entries:
print(f' {entry.value} {entry.name}')

Expand Down Expand Up @@ -136,7 +138,8 @@ def main():
calc_parser = subparsers.add_parser('calc', help='Calculator mode')
calc_parser.add_argument('--inbound', type=int, required=True, help='Inbound course to the holding point')
calc_parser.add_argument('--holding-radial', type=int, required=True, help='Hold radial as given by ATC or plate')
calc_parser.add_argument('--turn', type=str, default=Turns.RIGHT.value, choices=[t.value for t in Turns], help='Turn direction (defaults to right)')
calc_parser.add_argument('--turn', type=str, default=Turns.RIGHT.value, choices=[t.value for t in Turns],
help='Turn direction (defaults to right)')
calc_parser.set_defaults(func=calc)

args = parser.parse_args()
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pytest
pytest-cov
pycodestyle
pylint
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ def test_get_entry(holding_radial, turn, direct_radial, direct_reciprocal, inbou
(251, 71, 252, False),
])
def test_is_clockwise_between(radial_a, radial_b, course, result):
assert is_clockwise_between(radial_a, radial_b, course) is result
assert is_clockwise_between(radial_a, radial_b, course) is not result