-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 967f13e
Showing
18 changed files
with
7,019 additions
and
0 deletions.
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,8 @@ | ||
[bumpversion] | ||
current_version = 0.1.0 | ||
commit = True | ||
tag = True | ||
|
||
[bumpversion:file:setup.py] | ||
[bumpversion:file:serverless.yaml] | ||
[bumpversion:file:package.json] |
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,2 @@ | ||
dataplatform: | ||
- '**/*' |
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,43 @@ | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
paths-ignore: | ||
- '**/*.md' | ||
pull_request: | ||
branches: [main] | ||
paths-ignore: | ||
- '**/*.md' | ||
schedule: | ||
- cron: "0 6 * * 1" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
|
||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: ["python"] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@d13ca047ae14d02299ae648f2ba451622ecb7270 # v3.23.1 | ||
with: | ||
languages: ${{ matrix.language }} | ||
queries: +security-and-quality | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@d13ca047ae14d02299ae648f2ba451622ecb7270 # v3.23.1 |
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,33 @@ | ||
name: Deploy Dev | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '**/*.md' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy-dev: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 | ||
with: | ||
python-version: '3.11' | ||
- name: Install Python dependencies | ||
run: pip install tox | ||
- name: Test with tox | ||
run: tox -e py,flake8,black | ||
- uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 | ||
with: | ||
node-version: '18.x' | ||
- name: Install NPM dependencies | ||
run: npm install | ||
- name: Deploy Lambda functions | ||
run: | | ||
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_DEV }} \ | ||
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} \ | ||
./node_modules/.bin/sls deploy -s dev |
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,31 @@ | ||
name: Deploy Prod | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy-prod: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 | ||
with: | ||
python-version: '3.11' | ||
- name: Install Python dependencies | ||
run: pip install tox | ||
- name: Test with tox | ||
run: tox -e py,flake8,black | ||
- uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 | ||
with: | ||
node-version: '18.x' | ||
- name: Install NPM dependencies | ||
run: npm install | ||
- name: Deploy Lambda functions | ||
run: | | ||
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_PROD }} \ | ||
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }} \ | ||
./node_modules/.bin/sls deploy -s prod |
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,19 @@ | ||
name: "Pull Request Labeler" | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
triage: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
actions: read | ||
contents: read | ||
issues: write | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # v4.3.0 | ||
with: | ||
repo-token: "${{ secrets.GITHUB_TOKEN }}" |
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,20 @@ | ||
name: PR Tests | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- '**/*.md' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 | ||
with: | ||
python-version: '3.11' | ||
- name: Install dependencies | ||
run: pip install tox | ||
- name: Test with tox | ||
run: tox -e py,flake8,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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Distribution / packaging | ||
.Python | ||
env/ | ||
venv/ | ||
.*venv/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
.tox/ | ||
__pycache__ | ||
|
||
# Serverless directories | ||
.serverless | ||
node_modules/ | ||
|
||
.gradle/ | ||
.terraform/ | ||
*~ | ||
|
||
# Jetbrains | ||
.idea/ |
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,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright © 2021 Oslo kommune | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,78 @@ | ||
.DEV_PROFILE := okdata-dev | ||
.PROD_PROFILE := okdata-prod | ||
|
||
GLOBAL_PY := python3 | ||
BUILD_VENV ?= .build_venv | ||
BUILD_PY := $(BUILD_VENV)/bin/python | ||
|
||
.PHONY: init | ||
init: node_modules $(BUILD_VENV) | ||
|
||
node_modules: package.json package-lock.json | ||
npm install | ||
|
||
$(BUILD_VENV): | ||
$(GLOBAL_PY) -m venv $(BUILD_VENV) | ||
$(BUILD_PY) -m pip install -U pip | ||
|
||
.PHONY: format | ||
format: $(BUILD_VENV)/bin/black | ||
$(BUILD_PY) -m black . | ||
|
||
.PHONY: test | ||
test: $(BUILD_VENV)/bin/tox | ||
$(BUILD_PY) -m tox -p auto -o | ||
|
||
.PHONY: upgrade-deps | ||
upgrade-deps: $(BUILD_VENV)/bin/pip-compile | ||
$(BUILD_VENV)/bin/pip-compile -U | ||
|
||
.PHONY: deploy | ||
deploy: login-dev init format test | ||
@echo "\nDeploying to stage: dev\n" | ||
sls deploy --stage dev --aws-profile $(.DEV_PROFILE) | ||
|
||
.PHONY: deploy-prod | ||
deploy-prod: login-prod init format is-git-clean test | ||
sls deploy --stage prod --aws-profile $(.PROD_PROFILE) | ||
|
||
.PHONY: undeploy | ||
undeploy: login-dev init | ||
@echo "\nUndeploying stage: dev\n" | ||
sls remove --stage dev --aws-profile $(.DEV_PROFILE) | ||
|
||
.PHONY: undeploy-prod | ||
undeploy-prod: login-prod init | ||
@echo "\nUndeploying stage: prod\n" | ||
sls remove --stage prod --aws-profile $(.PROD_PROFILE) | ||
|
||
.PHONY: login-dev | ||
login-dev: init | ||
aws sts get-caller-identity --profile $(.DEV_PROFILE) || aws sso login --profile=$(.DEV_PROFILE) | ||
|
||
.PHONY: login-prod | ||
login-prod: init | ||
aws sts get-caller-identity --profile $(.PROD_PROFILE) || aws sso login --profile=$(.PROD_PROFILE) | ||
|
||
.PHONY: is-git-clean | ||
is-git-clean: | ||
@status=$$(git fetch origin && git status -s -b) ;\ | ||
if test "$${status}" != "## main...origin/main"; then \ | ||
echo; \ | ||
echo Git working directory is dirty, aborting >&2; \ | ||
false; \ | ||
fi | ||
|
||
.PHONY: build | ||
build: $(BUILD_VENV)/bin/wheel $(BUILD_VENV)/bin/twine | ||
$(BUILD_PY) setup.py sdist bdist_wheel | ||
|
||
### | ||
# Python build dependencies | ||
## | ||
|
||
$(BUILD_VENV)/bin/pip-compile: $(BUILD_VENV) | ||
$(BUILD_PY) -m pip install -U pip-tools | ||
|
||
$(BUILD_VENV)/bin/%: $(BUILD_VENV) | ||
$(BUILD_PY) -m pip install -U $* |
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,37 @@ | ||
# okdata-data-collectors | ||
|
||
Data collector jobs for the Origo dataplatform. | ||
|
||
## Setup | ||
|
||
```sh | ||
make init | ||
``` | ||
|
||
## Test | ||
|
||
Tests are run using [tox](https://pypi.org/project/tox/): | ||
|
||
```sh | ||
make test | ||
``` | ||
|
||
For tests and linting we use [pytest](https://pypi.org/project/pytest/), | ||
[flake8](https://pypi.org/project/flake8/), and | ||
[black](https://pypi.org/project/black/). | ||
|
||
## Deploy | ||
|
||
GitHub Actions deploys to dev and prod on push to `main`. | ||
|
||
You can also deploy from a local machine to dev with: | ||
|
||
```sh | ||
make deploy | ||
``` | ||
|
||
Or to prod with: | ||
|
||
```sh | ||
make deploy-prod | ||
``` |
Oops, something went wrong.