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

Fix publish workflow #352

Merged
merged 4 commits into from
Jun 16, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/deps_lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Testing, linting, and OpenAPI validation
name: CI tests

on:
pull_request:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/publish-on-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ jobs:
- name: Commit files
run: |
git config --local user.email "dev@optimade.org"
git config --local user.name "optimade_devs"
mv CHANGELOG.md docs/
git config --local user.name "OPTIMADE Developers"
mv -f CHANGELOG.md docs/

git add docs/CHANGELOG.md
git add openapi/*
git commit -m 'Release Updates' && echo ::set-env name=push::1 || echo "No changes to CHANGELOG.md"
git add openapi/index_openapi.json openapi/openapi.json
echo "::set-env name=push::0"
git commit -m 'Release Updates' && echo "::set-env name=push::1" || echo "No changes to CHANGELOG.md"

- name: Push changes
if: env.push == 1
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
context: .
dockerfile: Dockerfile
args:
CONFIG_FILE: .ci/docker_config.json
CONFIG_FILE: .docker/docker_config.json
PORT: 5000
environment:
MAIN: main
Expand All @@ -21,7 +21,7 @@ services:
context: .
dockerfile: Dockerfile
args:
CONFIG_FILE: .ci/docker_config.json
CONFIG_FILE: .docker/docker_config.json
PORT: 5001
environment:
MAIN: main_index
Expand Down
40 changes: 21 additions & 19 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ def parse_spec_for_filters(_):
else:
filters.append(_filter)

with open(filter_path, "w") as f:
with open(filter_path, "w") as handle:
for _filter in filters:
f.write(_filter + "\n")
handle.write(_filter + "\n")

with open(optional_filter_path, "w") as f:
with open(optional_filter_path, "w") as handle:
for _filter in optional_filters:
f.write(_filter + "\n")
handle.write(_filter + "\n")


@task
Expand All @@ -128,8 +128,9 @@ def generate_openapi(_):

if not TOP_DIR.joinpath("openapi").exists():
os.mkdir(TOP_DIR.joinpath("openapi"))
with open(TOP_DIR.joinpath("openapi/local_openapi.json"), "w") as f:
json.dump(app.openapi(), f, indent=2)
with open(TOP_DIR.joinpath("openapi/local_openapi.json"), "w") as handle:
json.dump(app.openapi(), handle, indent=2)
handle.write("\n") # Final empty EOL


@task
Expand All @@ -139,24 +140,25 @@ def generate_index_openapi(_):

if not TOP_DIR.joinpath("openapi").exists():
os.mkdir(TOP_DIR.joinpath("openapi"))
with open(TOP_DIR.joinpath("openapi/local_index_openapi.json"), "w") as f:
json.dump(app_index.openapi(), f, indent=2)
with open(TOP_DIR.joinpath("openapi/local_index_openapi.json"), "w") as handle:
json.dump(app_index.openapi(), handle, indent=2)
handle.write("\n") # Final empty EOL


@task(pre=[generate_openapi, generate_index_openapi])
def check_openapi_diff(_):
"""Checks the Generated OpenAPI spec against what is stored in the repo"""
with open(TOP_DIR.joinpath("openapi/openapi.json")) as f:
openapi = json.load(f)
with open(TOP_DIR.joinpath("openapi/openapi.json")) as handle:
openapi = json.load(handle)

with open(TOP_DIR.joinpath("openapi/local_openapi.json")) as f:
local_openapi = json.load(f)
with open(TOP_DIR.joinpath("openapi/local_openapi.json")) as handle:
local_openapi = json.load(handle)

with open(TOP_DIR.joinpath("openapi/index_openapi.json")) as f:
index_openapi = json.load(f)
with open(TOP_DIR.joinpath("openapi/index_openapi.json")) as handle:
index_openapi = json.load(handle)

with open(TOP_DIR.joinpath("openapi/local_index_openapi.json")) as f:
local_index_openapi = json.load(f)
with open(TOP_DIR.joinpath("openapi/local_index_openapi.json")) as handle:
local_index_openapi = json.load(handle)

openapi_diff = diff(openapi, local_openapi)
if openapi_diff != {}:
Expand Down Expand Up @@ -201,6 +203,6 @@ def update_api_shield(_):

shields_json = Path(__file__).parent.resolve().joinpath("optimade-version.json")

with open(shields_json, "w") as fp:
json.dump(shield, fp, indent=2)
fp.write("\n") # Add newline cause Py JSON does not
with open(shields_json, "w") as handle:
json.dump(shield, handle, indent=2)
handle.write("\n") # Add newline cause Py JSON does not