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

Python implementations on the side; yet to complete the days that I have so far #10

Merged
merged 7 commits into from
Aug 23, 2024
Merged
22 changes: 11 additions & 11 deletions .github/workflows/tests.yml → .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go Test
name: Go Tests

on:
push:
Expand All @@ -8,7 +8,7 @@ on:
workflow_dispatch:

jobs:
diff:
go-diff:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
Expand All @@ -23,37 +23,37 @@ jobs:
echo "Changed directories: $changed_dirs"
echo "matrix=$changed_dirs" >> $GITHUB_OUTPUT

test:
needs: diff
go-test:
needs: go-diff
runs-on: ubuntu-latest
if: needs.diff.outputs.matrix != '[]'
if: needs.go-diff.outputs.matrix != '[]'
strategy:
fail-fast: false
matrix:
dir: ${{fromJson(needs.diff.outputs.matrix)}}
dir: ${{fromJson(needs.go-diff.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "^1.23.0"
- name: Run tests in changed directories
- name: Run Go tests in changed directories
run: |
for dir in "${{ matrix.dir }}"; do
if [ -d "$dir" ]; then
echo "Running tests in $dir"
echo "Running Go tests in $dir"
(cd "$dir" && go test ./...)
else
echo "No Go files in $dir"
fi
done

test-main:
go-test-main:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "^1.23.0"
- name: Run tests
run: go test ./...
- name: Run Go tests
run: go test ./...
59 changes: 59 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Python Tests

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
python-diff:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- id: set-matrix
run: |
changed_dirs=$(git diff --name-only origin/${{ github.base_ref }} | grep '.py$' | xargs -I {} dirname {} | uniq | awk '{print "\"" $0 "\""}' | jq -R -s -c 'split("\n")[:-1]')
echo "Changed directories: $changed_dirs"
echo "matrix=$changed_dirs" >> $GITHUB_OUTPUT

python-test:
needs: python-diff
runs-on: ubuntu-latest
if: needs.python-diff.outputs.matrix != '[]'
strategy:
fail-fast: false
matrix:
dir: ${{fromJson(needs.python-diff.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Run Python tests in changed directories
run: |
for dir in "${{ matrix.dir }}"; do
if [ -d "$dir" ]; then
echo "Running Python tests in $dir"
(cd "$dir" && python -m unittest discover)
else
echo "No Python files in $dir"
fi
done

python-test-main:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Run Python tests
run: python -m unittest discover
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ go.work
# Misc
.DS_Store
.aider*

# Python
*.pyc
__pycache__/
.pytest_cache/
Empty file added requirements.txt
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading