Skip to content

Commit

Permalink
Chore: Further linting fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Watkins <[email protected]>
  • Loading branch information
ModeSevenIndustrialSolutions committed Nov 21, 2023
1 parent 5271f2f commit f8ac6bd
Show file tree
Hide file tree
Showing 10 changed files with 405 additions and 101 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ name: CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run auto-tests
run: tox
- name: Run auto-tests
run: tox
41 changes: 20 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@ name: Publish on PyPI
on:
push:
tags:
- v*
- v*

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.OSC_PHYSRISK_API_PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.OSC_PHYSRISK_API_PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
122 changes: 61 additions & 61 deletions .github/workflows/test-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
name: Run tests, build and push image

env:
APP_NAME: "physrisk-api"
IMAGE_REGISTRY: "quay.io/os-climate"
IMAGE_TAGS: ""
APP_NAME: 'physrisk-api'
IMAGE_REGISTRY: 'quay.io/os-climate'
IMAGE_TAGS: ''

on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
Expand All @@ -17,69 +17,69 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check for required secrets
uses: actions/github-script@v4
with:
script: |
const secrets = {
OSC_PHYSRISK_API_QUAY_USER: `${{ secrets.OSC_PHYSRISK_API_QUAY_USER }}`,
OSC_PHYSRISK_API_QUAY_TOKEN: `${{ secrets.OSC_PHYSRISK_API_QUAY_TOKEN }}`,
};
- name: Check for required secrets
uses: actions/github-script@v4
with:
script: |
const secrets = {
OSC_PHYSRISK_API_QUAY_USER: `${{ secrets.OSC_PHYSRISK_API_QUAY_USER }}`,
OSC_PHYSRISK_API_QUAY_TOKEN: `${{ secrets.OSC_PHYSRISK_API_QUAY_TOKEN }}`,
};
const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => {
if (value.length === 0) {
core.error(`Secret "${name}" is not set`);
return true;
}
core.info(`✔️ Secret "${name}" is set`);
return false;
});
const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => {
if (value.length === 0) {
core.error(`Secret "${name}" is not set`);
return true;
}
core.info(`✔️ Secret "${name}" is set`);
return false;
});
if (missingSecrets.length > 0) {
core.setFailed(`❌ At least one required secret is not set in the repository. \n` +
"You can add it using:\n" +
"GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" +
"GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" +
"Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example");
}
else {
core.info(`✅ All the required secrets are set`);
}
if (missingSecrets.length > 0) {
core.setFailed(`❌ At least one required secret is not set in the repository. \n` +
"You can add it using:\n" +
"GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" +
"GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" +
"Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example");
}
else {
core.info(`✅ All the required secrets are set`);
}
- name: Check out repository
uses: actions/checkout@v2
- name: Check out repository
uses: actions/checkout@v2

- name: Determine app name
if: env.APP_NAME == ''
run: |
echo "APP_NAME=$(basename $PWD)" | tee -a $GITHUB_ENV
- name: Determine app name
if: env.APP_NAME == ''
run: |
echo "APP_NAME=$(basename $PWD)" | tee -a $GITHUB_ENV
- name: Determine image tags
if: env.IMAGE_TAGS == ''
run: |
echo "IMAGE_TAGS=latest ${GITHUB_SHA::12}" | tee -a $GITHUB_ENV
- name: Determine image tags
if: env.IMAGE_TAGS == ''
run: |
echo "IMAGE_TAGS=latest ${GITHUB_SHA::12}" | tee -a $GITHUB_ENV
# https://github.com/redhat-actions/buildah-build#readme
- name: Build from Dockerfile
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.APP_NAME }}
tags: ${{ env.IMAGE_TAGS }}
# https://github.com/redhat-actions/buildah-build#readme
- name: Build from Dockerfile
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.APP_NAME }}
tags: ${{ env.IMAGE_TAGS }}

# If you don't have a Dockerfile/Containerfile, refer to https://github.com/redhat-actions/buildah-build#scratch-build-inputs
# Or, perform a source-to-image build using https://github.com/redhat-actions/s2i-build
# Otherwise, point this to your Dockerfile/Containerfile relative to the repository root.
dockerfiles: |
./Dockerfile
# If you don't have a Dockerfile/Containerfile, refer to https://github.com/redhat-actions/buildah-build#scratch-build-inputs
# Or, perform a source-to-image build using https://github.com/redhat-actions/s2i-build
# Otherwise, point this to your Dockerfile/Containerfile relative to the repository root.
dockerfiles: |
./Dockerfile
# https://github.com/redhat-actions/push-to-registry#readme
- name: Push to registry
id: push-image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ secrets.OSC_PHYSRISK_API_QUAY_USER }}
password: ${{ secrets.OSC_PHYSRISK_API_QUAY_TOKEN }}
# https://github.com/redhat-actions/push-to-registry#readme
- name: Push to registry
id: push-image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ secrets.OSC_PHYSRISK_API_QUAY_USER }}
password: ${{ secrets.OSC_PHYSRISK_API_QUAY_TOKEN }}
4 changes: 2 additions & 2 deletions .thoth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ runtime_environments:
- name: default
operating_system:
name: ubi
version: "8"
python_version: "3.8"
version: '8'
python_version: '3.8'
recommendation_type: latest

managers:
Expand Down
14 changes: 12 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Contributing to phsyrisk-api

## Getting started

To get set up, clone and enter the repo.

```
git clone [email protected]:os-climate/physrisk-api.git
cd physrisk-api
```

We recommend using [pipenv](https://pipenv.pypa.io/en/latest/) for a
consistent working environment.

```
pip install pipenv
pipenv install
Expand All @@ -20,8 +23,9 @@ When adding a package for use in new or improved functionality,
testing or development, `pipenv install -d <package-name>`.

## Development

Patches may be contributed via pull requests to
https://github.com/os-climate/physrisk-api.
<https://github.com/os-climate/physrisk-api>.

All changes must pass the automated test suite, along with various static
checks.
Expand All @@ -30,13 +34,15 @@ checks.
[isort](https://pycqa.github.io/isort/) import ordering are enforced
and enabling automatic formatting via [pre-commit](https://pre-commit.com/)
is recommended:

```
pre-commit install
```

To ensure compliance with static check tools, developers may wish to run black and isort against modified files.

E.g.,

```
# auto-sort imports
isort .
Expand All @@ -45,6 +51,7 @@ black .
```

Code can then be tested using tox.

```
# run static checks and unit tests
tox
Expand All @@ -57,13 +64,16 @@ tox -e cov
```

To run the application locally, run either of the following commands;

```
docker-compose up
# or
podman-compose up
```
One may then make requests of https://0.0.0.0:8080.

One may then make requests of <https://0.0.0.0:8080>.

## Releasing

Currently, this service is released automatically to quay.io and manually
deployed onto OpenShift.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ physrisk-lib = ">=0.19.0"
flask-jwt-extended = "*"

[dev-packages]
pdm = "*"
pytest = "*"
tox = "*"
black = "*"
Expand Down
Loading

0 comments on commit f8ac6bd

Please sign in to comment.