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

Baseline GitHub Actions #2

Merged
merged 3 commits into from
Dec 4, 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
45 changes: 45 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Check formatting, version bumping and unit tests

on:
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.0
with:
poetry-version: '1.8.3'

- name: Install dependencies
run: poetry install --no-root

- name: Fetch all branches
run: git fetch --all

- name: Make version check script executable
run: chmod +x check_poetry_version.sh

- name: Check version bump in pyproject.toml
run: bash ./check_poetry_version.sh

- name: Check code formatting
run: make check

- name: Run tests
run: make test




4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,6 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea
*.csv
*.zip
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
install:
poetry install --no-root

test:
poetry run pytest ./tests -vv

update:
poetry update

format:
poetry run ruff format .
poetry run ruff check . --fix

check:
poetry run ruff format --check .

kaggle-download:
kaggle competitions download -c titanic
mkdir -p ./data/titanic
unzip titanic.zip -d ./data/titanic
rm titanic.zip
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# kaggle-tutorial
# Kaggle Tutorial

Kick-off repository for starting with Kaggle!

- [How to Use Kaggle](https://www.kaggle.com/docs/api#getting-started-installation-&-authentication) - official guide
how to use Kaggle via API.
- [Titanic Competition](https://www.kaggle.com/competitions/titanic/overview/evaluation)

Download the dataset using the following commands:
```shell
kaggle competitions download -c titanic
mkdir -p ./data/titanic
unzip titanic.zip -d ./data/titanic
rm titanic.zip
```
11 changes: 11 additions & 0 deletions check_poetry_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

base_version=$(git show origin/main:pyproject.toml | grep '^version = ' | cut -d '"' -f2)
branch_version=$(grep '^version = ' pyproject.toml | cut -d '"' -f2)

if [ "$(printf '%s\n' "$base_version" "$branch_version" | sort -V | tail -n 1)" = "$base_version" ]; then
echo "Version in pyproject.toml on branch must be higher than on main."
exit 1
else
echo "Version check passed: branch version is higher."
fi
464 changes: 464 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.poetry]
name = "kaggle-tutorial"
version = "0.2.0"
description = ""
authors = ["Jan Karas <mygnirut@gmail.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
kaggle = "^1.6.17"
ruff = "^0.8.1"
pytest = "^8.3.4"
numpy = "^2.1.3"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file added tests/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions tests/unit_tests/test_something.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np


def test_zeros():
matrix = np.array([[0, 0, 0], [0, 0, 0]])
assert np.array_equal(matrix, np.zeros_like(matrix))


def test_random_matrix():
matrix = np.ones((3, 3))
assert matrix.shape == (3, 3)
assert np.array_equal(matrix, np.ones((3, 3))) # Do not change this line
Loading