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

Make CI compatible both for Go & Python #39

Merged
merged 7 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ jobs:
runCIsInMultipleProject:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code
- uses: actions/checkout@v3

# Step 2: Set up Golang
- uses: actions/setup-go@v4
with:
go-version: '>=1.17.0'
# Step 3: Set up Python
- uses: actions/setup-python@v4
with:
python-version: '3.10'

# Step 4: Run the combined script
- run: bash run-ci.sh
Empty file.
3 changes: 3 additions & 0 deletions advent_of_code/2024(python)/day1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

def add(a:int, b:int) -> int :
return a+b
11 changes: 11 additions & 0 deletions advent_of_code/2024(python)/test_day1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest

from day1 import add

class TestSample(unittest.TestCase):

def test_add(self):
self.assertEqual(add(2,4), 6)

if __name__ == "__main__":
unittest.main()
25 changes: 24 additions & 1 deletion run-ci.sh
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
cd advent_of_code && cd 2021 && go test && cd ../2022 && go test && cd ../2023 && go test
cd advent_of_code

# For solutions with go
dir_go_list="2021 2022 2023 2024"
for dir in $dir_go_list; do
if [ -d "$dir" ]; then
echo "Entering directory: $dir"
cd "$dir" || exit 1

if go test ; then
echo "Tests passed in $dir"
else
echo "Tests failed in $dir"
fi

cd ..
fi
done

# For solutions with Python
# may need to use another list for python folders next year
echo "==entering Python solution folder=="
cd "2024(python)"
python -m unittest discover
Loading