-
Notifications
You must be signed in to change notification settings - Fork 0
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
Static analysis and ci #7
Open
MattF-NSIDC
wants to merge
17
commits into
main
Choose a base branch
from
static-analysis-and-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9bad512
Init static analysis config
mfisher87 1954131
Apply `black` formatting
mfisher87 26cbc30
Move json2datalad script into scripts dir
mfisher87 a35250a
Init GitHub Actions config
mfisher87 40b827c
Try setting `runs-on` for second step
mfisher87 a7b5808
Run `conda init` in GHA workflow
mfisher87 33cb5ba
Move datalad to runtime deps
mfisher87 b00f9ae
Try sourcing conda's activate script
mfisher87 b701a31
Try `conda init bash`
mfisher87 b051170
Try bash login shell
mfisher87 75cb1fd
Try using $CONDA envvar to activate
mfisher87 096c99c
Try using `conda-incubator/setup-miniconda` action
mfisher87 3e77095
Merge branch 'main' into static-analysis-and-ci
mfisher87 e887925
Address shellcheck messages
mfisher87 4789f4d
More consistent conditional expression
mfisher87 199fcb0
Fix typechecker errors
mfisher87 97f518a
Ensure parents of output directory exist
mfisher87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[flake8] | ||
max-line-length = 100 | ||
max-complexity = 8 | ||
|
||
# Temporary. Remove once black re-enabled: | ||
inline-quotes = ' | ||
|
||
# flake8-import-order | ||
application_import_names = cryo_data_ingest | ||
import_order_style = pycharm | ||
|
||
# D1: Ignore errors requiring docstrings on everything. | ||
# W503: Line breaks should occur after the binary operator to keep all variable names aligned. | ||
# E731: Lambda assignments are OK, use your best judgement. | ||
# C408: Unnecessary dict call - rewrite as a literal. | ||
ignore = D1,W503,E731,C408 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: "test" | ||
on: ["push"] | ||
jobs: | ||
# TODO: How to split environment setup and test steps into different jobs? | ||
test: | ||
defaults: | ||
run: | ||
shell: "bash -l {0}" | ||
|
||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: "actions/checkout@v3" | ||
|
||
- name: "Create conda environment" | ||
uses: "conda-incubator/setup-miniconda@v2" | ||
with: | ||
environment-file: "environment.yml" | ||
activate-environment: "cryo-data-ingest" | ||
miniforge-version: "latest" | ||
# TODO: Do we need the `setup-miniconda` action? Why not: | ||
# run: "conda env create" | ||
|
||
- name: "Run static analysis / tests" | ||
run: "inv test.ci" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[mypy] | ||
python_version = 3.10 | ||
incremental = True | ||
show_error_codes = True | ||
check_untyped_defs = True | ||
warn_unreachable = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
from pathlib import Path | ||
|
||
PACKAGE_DIR = Path(__file__).parent.parent | ||
PROJECT_DIR = PACKAGE_DIR.parent | ||
SCRIPTS_DIR = PROJECT_DIR / 'scripts' | ||
|
||
JSON_STORAGE_DIR = Path('/tmp/cryo-data-ingest') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[tool.black] | ||
skip-string-normalization = true | ||
|
||
|
||
[tool.isort] | ||
profile = "black" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"""Invoke tasks.""" | ||
|
||
from invoke import Collection | ||
|
||
from . import env, format, test | ||
|
||
ns = Collection() | ||
ns.add_collection(env) | ||
ns.add_collection(format) | ||
ns.add_collection(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from invoke import task | ||
|
||
from .util import PROJECT_DIR, print_and_run | ||
|
||
ENV_LOCKFILE = PROJECT_DIR / "environment-lock.yml" | ||
|
||
|
||
@task(default=True) | ||
def lock(ctx): | ||
"""Update the environment-lock.yml file from the current `cryo-data-ingest` environment.""" | ||
print_and_run(f"conda env export -n cryo-data-ingest > {ENV_LOCKFILE}") | ||
|
||
with open(ENV_LOCKFILE, "r") as f: | ||
lines = f.readlines() | ||
|
||
with open(ENV_LOCKFILE, "w") as f: | ||
for line in lines: | ||
# The prefix line contains machine-specific directory | ||
if line.startswith('prefix: '): | ||
continue | ||
|
||
# We don't want to use the NSIDC conda channel | ||
if '- nsidc' in line: | ||
continue | ||
|
||
# We want to replace the "defaults" channel with "nodefaults" so conda-forge | ||
# is used for everything. | ||
if '- defaults' in line: | ||
f.write(line.replace('- defaults', '- nodefaults')) | ||
continue | ||
|
||
f.write(line) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mankoff the
$verbose
variable previously had no effect. What do you think about this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? When processing the CLI arg/flags I had
set -o xtrace;
which made things very verbose. But this is a good addition.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, to be more clear, the
--verbose
flag does have an effect, but the$verbose
variable was not being used anywhere in the code. We could remove the$verbose
variable entirely and only doset -o xtrace
when the flag is passed? What do you think?