Skip to content

Commit 7e73556

Browse files
authored
Merge pull request #1 from lalithkota/develop
Added template rendering, storage into s3, subscribe routes, receive routes
2 parents 5ea4eea + 13f19e2 commit 7e73556

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2879
-2
lines changed

.copier-answers.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Do NOT update manually; changes here will be overwritten by Copier
2+
_commit: af08ec1
3+
_src_path: https://github.com/openg2p/openg2p-fastapi-template
4+
github_ci_docker_build: true
5+
github_ci_openapi_publish: true
6+
github_ci_precommit: true
7+
github_ci_pypi_publish: true
8+
github_ci_tests: true
9+
github_ci_tests_codecov: true
10+
module_name: openg2p_websub_print_listener
11+
org_name: OpenG2P
12+
org_slug: OpenG2P
13+
package_name: openg2p-websub-print-listener
14+
repo_name: OpenG2P WebSub Print Listener
15+
repo_slug: openg2p-websub-print-listener
16+

.dockerignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
.github
6+
7+
# CI
8+
.codeclimate.yml
9+
.travis.yml
10+
.taskcluster.yml
11+
12+
# Docker
13+
docker-compose.yml
14+
Dockerfile
15+
.docker
16+
.dockerignore
17+
18+
# Byte-compiled / optimized / DLL files
19+
**/__pycache__/
20+
**/*.py[cod]
21+
22+
# C extensions
23+
*.so
24+
25+
# Distribution / packaging
26+
.Python
27+
env/
28+
build/
29+
develop-eggs/
30+
dist/
31+
downloads/
32+
eggs/
33+
lib/
34+
lib64/
35+
parts/
36+
sdist/
37+
var/
38+
*.egg-info/
39+
.installed.cfg
40+
*.egg
41+
42+
# PyInstaller
43+
# Usually these files are written by a python script from a template
44+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
45+
*.manifest
46+
*.spec
47+
48+
# Installer logs
49+
pip-log.txt
50+
pip-delete-this-directory.txt
51+
52+
# Unit test / coverage reports
53+
htmlcov/
54+
.tox/
55+
.coverage
56+
.cache
57+
nosetests.xml
58+
coverage.xml
59+
60+
# Translations
61+
*.mo
62+
*.pot
63+
64+
# Django stuff:
65+
*.log
66+
67+
# Sphinx documentation
68+
docs/_build/
69+
70+
# PyBuilder
71+
target/
72+
73+
# Virtual environment
74+
.env
75+
.venv/
76+
venv/
77+
78+
# PyCharm
79+
.idea
80+
81+
# Python mode for VIM
82+
.ropeproject
83+
**/.ropeproject
84+
85+
# Vim swap files
86+
**/*.swp
87+
88+
# Code formatting
89+
.editorconfig
90+
.copier-answers.yml
91+
.pre-commit-config.yaml
92+
.ruff.toml
93+
.ruff_cache
94+
95+
# VS Code
96+
.vscode/
97+
98+
# K8s & Helm charts
99+
charts

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Configuration for known file extensions
2+
[*.{css,js,json,less,md,py,rst,sass,scss,xml,yaml,yml,toml,jinja}]
3+
charset = utf-8
4+
end_of_line = lf
5+
indent_size = 4
6+
indent_style = space
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.{yml,yaml,rst,md,jinja}]
11+
indent_size = 2
12+
13+
# Do not configure editor for libs and autogenerated content
14+
[{*/static/{lib,src/lib}/**,*/static/description/index.html,*/readme/../README.rst}]
15+
charset = unset
16+
end_of_line = unset
17+
indent_size = unset
18+
indent_style = unset
19+
insert_final_newline = false
20+
trim_trailing_whitespace = false

.github/workflows/docker-build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build Docker and Push
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
docker-build:
9+
name: Docker Build and Push
10+
runs-on: ubuntu-latest
11+
env:
12+
NAMESPACE: ${{ secrets.docker_hub_organisation || 'openg2p' }}
13+
SERVICE_NAME: openg2p-websub-print-listener
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Docker build
17+
run: |
18+
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
19+
20+
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
21+
22+
# Change all uppercase to lowercase
23+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
24+
VERSION=$BRANCH_NAME
25+
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then
26+
VERSION=develop
27+
fi
28+
echo IMAGE_ID=$IMAGE_ID
29+
echo VERSION=$VERSION
30+
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
31+
echo VERSION=$VERSION >> $GITHUB_ENV
32+
33+
docker build . \
34+
--file Dockerfile \
35+
--tag $IMAGE_ID:$VERSION
36+
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' ]]; then
37+
export DOCKER_PUSH="true"
38+
echo DOCKER_PUSH=$DOCKER_PUSH >> $GITHUB_ENV
39+
fi
40+
- name: Docker push
41+
if: env.DOCKER_PUSH == 'true'
42+
run: |
43+
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
44+
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}

.github/workflows/helm-push.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Publish OpenG2P Helm charts on
2+
3+
on:
4+
push:
5+
tags-ignore:
6+
- '**'
7+
branches:
8+
- 1.*
9+
- develop
10+
- main
11+
workflow_dispatch:
12+
inputs:
13+
forcePublishCharts:
14+
description: "Force publish Charts?"
15+
default: "*"
16+
type: string
17+
18+
jobs:
19+
generate-charts:
20+
runs-on: ubuntu-latest
21+
env:
22+
SKIP: 'FALSE'
23+
RANCHER_CHART_FILTER: "openg2p.org/add-to-rancher"
24+
FORCE_PUBLISH_CHARTS: "${{ inputs.forcePublishCharts || '' }}"
25+
defaults:
26+
run:
27+
shell: bash
28+
steps:
29+
- name: Checkout Repository
30+
uses: actions/checkout@v3
31+
32+
- id: files
33+
if: env.FORCE_PUBLISH_CHARTS == ''
34+
uses: jitterbit/get-changed-files@v1
35+
36+
- name: save helm/charts to tmp.txt file
37+
run: |
38+
touch charts-list.txt
39+
if [ -n "${FORCE_PUBLISH_CHARTS}" ]; then
40+
for chart in charts/${FORCE_PUBLISH_CHARTS}/; do
41+
chart="${chart#charts/}"
42+
chart="${chart%/}"
43+
echo "$chart" >> charts-list.txt
44+
done
45+
else
46+
for changed_file in ${{ steps.files.outputs.all }}; do
47+
if [[ ${changed_file} =~ ^charts ]]; then
48+
chart_name=$(echo "${changed_file}" | awk -F/ '/^[charts]/{print $2}')
49+
echo $chart_name >> charts-list.txt;
50+
echo "Saved $chart_name chart to charts-list.txt"
51+
fi
52+
done
53+
cat charts-list.txt | sort | uniq > charts-list-unique.txt
54+
mv charts-list-unique.txt charts-list.txt
55+
fi
56+
echo "List of charts to be published";
57+
cat charts-list.txt
58+
59+
- name: Generate tar files
60+
run: |
61+
if [[ ! -s charts-list.txt ]]; then
62+
echo "::warning::No Charts to publish";
63+
echo "SKIP=TRUE" >> $GITHUB_ENV
64+
else
65+
for chartpath in charts/*/; do
66+
if [ -f ${chartpath}Chart.yaml ]; then
67+
helm dep up $chartpath
68+
fi
69+
done
70+
RANCHER_CHARTS=()
71+
while IFS= read -r chartpath; do
72+
echo "chartpath: $chartpath"
73+
chartname=$(basename "$chartpath")
74+
if [ -f charts/${chartname}/Chart.yaml ]; then
75+
echo "Chartname: $chartname"
76+
helm package charts/$chartpath
77+
is_rancher_chart=$(grep "$RANCHER_CHART_FILTER" charts/${chartpath%*/}/Chart.yaml || true)
78+
if [ -n "$is_rancher_chart" ]; then
79+
RANCHER_CHARTS+=("$chartname")
80+
fi
81+
fi
82+
done < charts-list.txt
83+
echo "RANCHER_CHARTS=${RANCHER_CHARTS[@]}" >> $GITHUB_ENV
84+
rm charts-list.txt
85+
fi
86+
87+
shopt -s nocasematch
88+
if [[ '${{ github.repository_owner }}' != 'OpenG2P' ]]; then
89+
echo "SKIP=TRUE" >> $GITHUB_ENV
90+
fi
91+
- name: Upload tar as Artifact
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: charts
95+
path: ./*.tgz
96+
if: env.SKIP != 'TRUE'
97+
98+
- name: Checkout branch for publishing
99+
uses: actions/checkout@v3
100+
with:
101+
repository: 'openg2p/openg2p-helm'
102+
ref: gh-pages
103+
token: ${{ secrets.OPENG2P_BOT_GITHUB_PAT }}
104+
if: env.SKIP != 'TRUE'
105+
106+
- name: Download tar from Artifacts
107+
uses: actions/download-artifact@v4
108+
with:
109+
name: charts
110+
path: ./
111+
if: env.SKIP != 'TRUE'
112+
113+
- name: Update index.yaml
114+
run: |
115+
helm repo index --url https://openg2p.github.io/openg2p-helm/ .
116+
for chartname in $RANCHER_CHARTS; do
117+
cp ${chartname}*.tgz rancher/
118+
done
119+
helm repo index --url https://openg2p.github.io/openg2p-helm/ --merge rancher/index.yaml rancher
120+
for chartname in $RANCHER_CHARTS; do
121+
rm rancher/${chartname}*.tgz || true
122+
done
123+
if: env.SKIP != 'TRUE'
124+
125+
- name: Commit Changes to repository
126+
uses: EndBug/add-and-commit@v7
127+
with:
128+
branch: gh-pages
129+
author_name: openg2pbot
130+
author_email: [email protected]
131+
default_author: user_info
132+
message: 'added helm charts for publish openg2p/openg2p-websub-print-listener@${{ github.sha }}'
133+
add: './*.tgz ./index.yaml rancher/index.yaml'
134+
if: env.SKIP != 'TRUE'

.github/workflows/openapi-push.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: openapi publish on push
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
openapi-publish:
9+
name: OpenAPI Generate and Publish
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Get branch name (merge)
14+
run: |
15+
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
16+
- name: Setup python for openapi generate
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.10"
20+
- name: Install app
21+
run: |
22+
python -m pip install git+https://github.com/openg2p/openg2p-fastapi-common@develop\#subdirectory=openg2p-fastapi-common
23+
python -m pip install .
24+
- name: Generate openapi json
25+
run: |
26+
mkdir -p api-docs/generated
27+
python3 main.py getOpenAPI api-docs/generated/openapi.json
28+
if ! [ -z "$(git status --porcelain=v1 2>/dev/null -- api-docs/generated/openapi.json)" ]; then
29+
shopt -s nocasematch
30+
if [[ ${{ github.repository_owner }} == 'OpenG2P' ]]; then
31+
export OPENAPI_CHANGED="true"
32+
echo OPENAPI_CHANGED=$OPENAPI_CHANGED >> $GITHUB_ENV
33+
fi
34+
fi
35+
- name: Commit Changes
36+
uses: EndBug/add-and-commit@v7
37+
if: env.OPENAPI_CHANGED == 'true'
38+
with:
39+
default_author: github_actions
40+
message: "Generated new openapi.json on push to ${{ github.event.inputs.git-ref }}"
41+
add: "api-docs/generated/openapi.json"
42+
- name: Setup nodejs
43+
uses: actions/setup-node@v4
44+
if: env.OPENAPI_CHANGED == 'true'
45+
with:
46+
node-version: '18'
47+
- name: Publish to stoplight
48+
if: env.OPENAPI_CHANGED == 'true'
49+
run: |
50+
npx @stoplight/cli@5 push --ci-token ${{ secrets.STOPLIGHT_PROJECT_TOKEN }} --url https://openg2p.stoplight.io --branch ${{ env.BRANCH_NAME }} --directory api-docs/generated

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
workflow_dispatch:
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-python@v3
14+
- uses: pre-commit/[email protected]
15+
with:
16+
extra_args: --all-files --show-diff-on-failure

0 commit comments

Comments
 (0)