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

Add windows to CI #319

Merged
merged 59 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a16d879
Add windows to CI
jayqi Aug 31, 2023
4a8f093
Try different shebang per https://github.com/actions/runner-images/is…
jayqi Aug 31, 2023
bd2732c
Revert "Try different shebang per https://github.com/actions/runner-i…
jayqi Aug 31, 2023
6867e40
Try setting PATH
jayqi Aug 31, 2023
89e6a03
Reduce matrix for testing
jayqi Aug 31, 2023
42c9752
Set default shell to bash
jayqi Aug 31, 2023
bafee55
Fix wrong syntax
jayqi Aug 31, 2023
5928598
Explicitly set bash path in test
jayqi Aug 31, 2023
9b1b51c
Fix syntax error
jayqi Aug 31, 2023
ffee911
Fix mistake
jayqi Aug 31, 2023
cc08db7
Try installing GNU make instead of using available mingw32-make
jayqi Aug 31, 2023
c9b7661
Undo explicit bash executable
jayqi Aug 31, 2023
483109e
Set conda executable
jayqi Aug 31, 2023
4b323f6
Fix black
jayqi Aug 31, 2023
cf9b366
Add conda directory to system paths
jayqi Aug 31, 2023
6f54e4c
Clearer phony declaration
jayqi Aug 31, 2023
943b0d3
Add diagnostic printing
jayqi Sep 1, 2023
cbf91ef
More printing
jayqi Sep 1, 2023
3a1af3a
Check which make
jayqi Sep 1, 2023
844ac69
Try adding Git bin directory to path
jayqi Sep 1, 2023
8a03fce
Explicit bash shell
jayqi Sep 1, 2023
f2c8b1f
Try adding explicit PATH
jayqi Sep 1, 2023
a49a0c9
Try making path style consistent
jayqi Sep 1, 2023
e87d91f
Explicit conda executable
jayqi Sep 1, 2023
f708f7b
try using which
jayqi Sep 1, 2023
1c33e56
Try Scripts directory for adding to PATH
jayqi Sep 1, 2023
b55161b
Try removing unnecessary conda stuff
jayqi Sep 1, 2023
b50bbca
Separate check step
jayqi Sep 1, 2023
78d27d0
Install from conda-forge
jayqi Sep 1, 2023
6ea0d61
Missing colon
jayqi Sep 1, 2023
2b818e5
Try setup miniconda to see if it's faster
jayqi Sep 1, 2023
79c0c5a
Change default shell
jayqi Sep 1, 2023
0678c30
Use conda environment
jayqi Sep 1, 2023
80063d6
Skip which conda
jayqi Sep 1, 2023
092200e
Add to path anyways
jayqi Sep 1, 2023
0ead759
Try micromamba
jayqi Sep 1, 2023
85c8421
Use mamba as conda executable
jayqi Sep 1, 2023
f398721
Fix typo
jayqi Sep 1, 2023
b7d2e2e
micromamba shell hook
jayqi Sep 1, 2023
5483d53
Missing quote
jayqi Sep 1, 2023
bad1a56
Full micromamba path; add caching
jayqi Sep 1, 2023
2a3f5df
Try path instead
jayqi Sep 2, 2023
3a98e92
Remove backslash
jayqi Sep 2, 2023
a6b56ed
Use mambaforge instead of micromamba
jayqi Sep 2, 2023
a7c210c
Add conda to PATH
jayqi Sep 2, 2023
5f8f834
Use conda activate
jayqi Sep 2, 2023
631c86b
Try permissions hack
jayqi Sep 2, 2023
ffe5eab
Remove unneeded packages
jayqi Sep 2, 2023
4e612b9
Use different repo name per config
jayqi Sep 2, 2023
535c920
Cleanup
jayqi Sep 2, 2023
0ccc546
Fallbacks
jayqi Sep 2, 2023
728f937
Fix backwards check
jayqi Sep 2, 2023
b573cfe
Print test durations
jayqi Sep 2, 2023
7de1ad6
Try conda and defaults again
jayqi Sep 2, 2023
bd8c1f9
Don't change shell
jayqi Sep 2, 2023
bb20b6e
Normal shell
jayqi Sep 2, 2023
0962c13
Clean up
jayqi Sep 3, 2023
be17bcb
More cleanup
jayqi Sep 3, 2023
cb37084
More cleanup
jayqi Sep 5, 2023
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
43 changes: 42 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v3
Expand All @@ -58,11 +61,49 @@ jobs:
pyproject.toml
dev-requirements.txt

- name: Cache conda packages
uses: actions/cache@v2
env:
# Increase this value to reset cache explicitly
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('ccds/hook_utils/dependencies.py') }}

- name: Setup for Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
# Install GNU make
choco install --verbose make
# Add conda binaries directory to PATH so that conda is accessible
echo "${CONDA}\Scripts" >> $GITHUB_PATH
# Set bash executable explicitly since Make may pick wrong shell
echo "BASH_EXECUTABLE=$(which bash)" >> "$GITHUB_ENV"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
make requirements

- name: Check dependencies
run: |
if [[ -z "${BASH_EXECUTABLE}" ]]; then
bash --version
else
echo $BASH_EXECUTABLE
$BASH_EXECUTABLE --version
fi
which make
make --version
which conda
conda --version
which pipenv
pipenv --version
which virtualenv
virtualenv --version

- name: Run tests
run: |
make test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ docs-serve:
### TESTS

test: _prep
pytest -vvv
pytest -vvv --durations=0

test-fastest: _prep
pytest -vvv -FFF
Expand Down
14 changes: 7 additions & 7 deletions ccds/hook_utils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ def write_dependencies(

elif dependencies == "environment.yml":
with open(dependencies, "w") as f:
lines = [f"name: {repo_name}", "dependencies:"]
lines = [
f"name: {repo_name}",
"dependencies:",
]

lines += [f" - python={python_version}"]
lines += [f" - {p}" for p in packages if p not in pip_only_packages]

lines += [" - pip:"] + [
f" - {p}" for p in packages if p in pip_only_packages
]

lines += [" - pip:"]
lines += [f" - {p}" for p in packages if p in pip_only_packages]
pjbull marked this conversation as resolved.
Show resolved Hide resolved
lines += [" - -e ."]

lines += [f" - python={python_version}"]

f.write("\n".join(lines))

elif dependencies == "Pipfile":
Expand Down
2 changes: 0 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"isort",
"pip",
"python-dotenv",
"setuptools",
"wheel",
pjbull marked this conversation as resolved.
Show resolved Hide resolved
]

# {% if cookiecutter.dataset_storage.s3 %}
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ def _is_valid(config):
# remove invalid configs
configs = [c for c in configs if _is_valid(c)]

for c in configs:
for ind, c in enumerate(configs):
config = dict(c)
config.update(default_args)
config["repo_name"] += f"-{ind}"
pjbull marked this conversation as resolved.
Show resolved Hide resolved
yield config

# just do a single config if fast passed once or three times
Expand Down
12 changes: 10 additions & 2 deletions tests/test_creation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import json
import os
import sys
from pathlib import Path
from subprocess import PIPE, run

from conftest import bake_project


BASH_EXECUTABLE = os.getenv("BASH_EXECUTABLE", "bash")


def no_curlies(filepath):
"""Utility to make sure no curly braces appear in a file.
That is, was Jinja able to render everything?
Expand All @@ -21,7 +26,7 @@ def test_baking_configs(config, fast):
"""For every generated config in the config_generator, run all
of the tests.
"""
print("using config", config)
print("using config", json.dumps(config, indent=2))
with bake_project(config) as project_directory:
verify_folders(project_directory, config)
verify_files(project_directory, config)
Expand Down Expand Up @@ -139,7 +144,9 @@ def verify_makefile_commands(root, config):
)

result = run(
["bash", str(harness_path), str(root.resolve())], stderr=PIPE, stdout=PIPE
[BASH_EXECUTABLE, str(harness_path), str(root.resolve())],
stderr=PIPE,
stdout=PIPE,
)
result_returncode = result.returncode

Expand All @@ -149,6 +156,7 @@ def verify_makefile_commands(root, config):
encoding = "utf-8"

# normally hidden by pytest except in failure we want this displayed
print("PATH=", os.getenv("PATH"))
print("\n======================= STDOUT ======================")
print(result.stdout.decode(encoding))

Expand Down
11 changes: 8 additions & 3 deletions {{ cookiecutter.repo_name }}/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.PHONY: clean data lint format requirements sync_data_down sync_data_up

#################################################################################
# GLOBALS #
#################################################################################
Expand All @@ -9,13 +7,13 @@ PROJECT_NAME = {{ cookiecutter.repo_name }}
PYTHON_VERSION = {{ cookiecutter.python_version_number }}
PYTHON_INTERPRETER = python


#################################################################################
# COMMANDS #
#################################################################################

{% if cookiecutter.dependency_file != 'none' %}
## Install Python Dependencies
.PHONY: requirements
requirements:
{% if "requirements.txt" == cookiecutter.dependency_file -%}
pjbull marked this conversation as resolved.
Show resolved Hide resolved
$(PYTHON_INTERPRETER) -m pip install -U pip setuptools wheel
Expand All @@ -29,22 +27,26 @@ requirements:


## Delete all compiled Python files
.PHONY: clean
clean:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete

## Lint using flake8 and black (use `make format` to do formatting)
.PHONY: lint
lint:
flake8 {{ cookiecutter.module_name }}
black --check --config pyproject.toml {{ cookiecutter.module_name }}


## Format source code with black
.PHONY: format
format:
black --config pyproject.toml {{ cookiecutter.module_name }}

{% if not cookiecutter.dataset_storage.none %}
## Download Data from storage system
.PHONY: sync_data_down
sync_data_down:
{% if cookiecutter.dataset_storage.s3 -%}
aws s3 sync s3://{{ cookiecutter.dataset_storage.s3.bucket }}/data/\
Expand All @@ -57,6 +59,7 @@ sync_data_down:
{% endif %}

## Upload Data to storage system
.PHONY: sync_data_up
sync_data_up:
{% if cookiecutter.dataset_storage.s3 -%}
aws s3 sync s3://{{ cookiecutter.dataset_storage.s3.bucket }}/data/ data/\
Expand All @@ -71,6 +74,7 @@ sync_data_up:

{% if cookiecutter.environment_manager != 'none' %}
## Set up python interpreter environment
.PHONY: create_environment
create_environment:
{% if cookiecutter.environment_manager == 'conda' -%}
{% if cookiecutter.dependency_file != 'environment.yml' %}
Expand All @@ -94,6 +98,7 @@ create_environment:
#################################################################################

## Make Dataset
.PHONY: data
data: requirements
$(PYTHON_INTERPRETER) {{ cookiecutter.module_name }}/data/make_dataset.py

Expand Down
Loading