Skip to content

Commit 075a069

Browse files
committed
wip
1 parent aca9ee9 commit 075a069

Some content is hidden

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

73 files changed

+82749
-2
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/*

.eslintrc.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"extends": "plugin:@hapi/recommended",
3+
"parserOptions": {
4+
"ecmaVersion": 2020
5+
},
6+
"rules": {
7+
"eol-last": ["error", "always"],
8+
"no-unused-vars": "warn",
9+
"indent": ["error", 2, {"SwitchCase": 1}],
10+
"keyword-spacing": 1,
11+
// "linebreak-style": ["error", "unix"],
12+
"no-console": 2,
13+
"no-fallthrough": 0,
14+
"no-multi-spaces": 2,
15+
"no-shadow": 1,
16+
"no-use-before-define": [2, "nofunc"],
17+
"quotes": ["error", "single"],
18+
"semi": ["error", "always"],
19+
"padding-line-between-statements": "warn",
20+
"comma-dangle": ["error", "never"],
21+
"space-before-function-paren": ["warn", {
22+
"anonymous": "always",
23+
"named": "never",
24+
"asyncArrow": "always"
25+
}],
26+
"unicode-bom": ["error", "never"]
27+
}
28+
}

.github/workflows/build-branch.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build branch
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
8+
jobs:
9+
test:
10+
name: Run tests
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Use Node.js 18
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 18
18+
- run: npm ci
19+
- run: npm test
20+
build-latest:
21+
name: Build branch
22+
runs-on: ubuntu-latest
23+
env:
24+
PROJECT_ID: ${{ secrets.GCP_BUILD_PROJECT_ID }}
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
30+
- run: |
31+
sudo apt-get install python2.7
32+
export CLOUDSDK_PYTHON="/usr/bin/python2"
33+
34+
- uses: google-github-actions/setup-gcloud@v0
35+
with:
36+
version: "286.0.0"
37+
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
38+
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
39+
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}
40+
41+
- name: Extract branch name
42+
shell: bash
43+
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's/\//-/g')" >> $GITHUB_OUTPUT
44+
id: extract_branch
45+
46+
- name: Build
47+
run: |-
48+
gcloud builds submit \
49+
--quiet \
50+
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.extract_branch.outputs.branch }}"

.github/workflows/build-latest.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build latest
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
test:
9+
name: Run tests
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Use Node.js 18
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: 18
17+
- run: npm ci
18+
- run: npm test
19+
build-latest:
20+
name: Build latest
21+
runs-on: ubuntu-latest
22+
env:
23+
PROJECT_ID: ${{ secrets.GCP_BUILD_PROJECT_ID }}
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- run: |
30+
sudo apt-get install python2.7
31+
export CLOUDSDK_PYTHON="/usr/bin/python2"
32+
33+
- uses: google-github-actions/setup-gcloud@v0
34+
with:
35+
version: "286.0.0"
36+
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
37+
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
38+
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}
39+
40+
- name: Build
41+
run: |-
42+
gcloud builds submit \
43+
--quiet \
44+
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:latest"

.github/workflows/release.yaml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
test:
10+
name: Run tests
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Use Node.js 18
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 18
18+
- run: npm ci
19+
- run: npm test
20+
build:
21+
name: Build with google cloud
22+
runs-on: ubuntu-latest
23+
env:
24+
PROJECT_ID: ${{ secrets.GCP_BUILD_PROJECT_ID }}
25+
26+
# Extract version tags from tag
27+
steps:
28+
- name: Setup variables
29+
id: variables
30+
run: |
31+
TAG_NAME=${GITHUB_REF/refs\/tags\//}
32+
FULL_V_TAG=$(echo $TAG_NAME | sed -r 's/^v(.+)/\1/')
33+
MINOR_V_TAG=$(echo $FULL_V_TAG | sed -r -e 's/.*-(\w+)/\1/' -e 's/(^[0-9]+\.[0-9]+).*/\1/')
34+
MAJOR_V_TAG=$(echo $MINOR_V_TAG | sed -r -e 's/(^[a-z]+).*/\1/' -e 's/(^[0-9]+).*/\1/')
35+
36+
echo ::set-output name=full_version_tag::$FULL_V_TAG
37+
echo ::set-output name=minor_version_tag::$MINOR_V_TAG
38+
echo ::set-output name=major_version_tag::$MAJOR_V_TAG
39+
40+
- name: Checkout
41+
uses: actions/checkout@v3
42+
43+
- run: |
44+
sudo apt-get install python2.7
45+
export CLOUDSDK_PYTHON="/usr/bin/python2"
46+
47+
# Setup gcloud CLI
48+
- uses: google-github-actions/setup-gcloud@v0
49+
with:
50+
version: "286.0.0"
51+
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
52+
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
53+
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}
54+
55+
# Build and push image to Google Container Registry
56+
- name: Build
57+
run: |-
58+
gcloud builds submit \
59+
--quiet \
60+
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA"
61+
62+
- name: Tag image
63+
run: |-
64+
gcloud container images add-tag --quiet \
65+
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
66+
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.full_version_tag }}"
67+
68+
gcloud container images add-tag --quiet \
69+
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
70+
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.minor_version_tag }}"
71+
72+
gcloud container images add-tag --quiet \
73+
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
74+
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.major_version_tag }}"

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,8 @@ dist
128128
.yarn/build-state.yml
129129
.yarn/install-state.gz
130130
.pnp.*
131+
132+
# custom directory
133+
!custom/src/node/modules/hello/*
134+
!custom/test/node/hello/*
135+
uploads

.vscode/launch.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Attach to Node",
9+
"type": "node",
10+
"request": "attach",
11+
"port": 9229,
12+
"restart": true,
13+
"skipFiles": ["<node_internals>/**"]
14+
},
15+
]
16+
}

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"javascript.preferences.quoteStyle": "auto",
4+
"prettier.singleQuote": true
5+
}

CODE_OF_CONDUCT.md

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM node:20
2+
3+
LABEL vendor="Onify"
4+
LABEL code="nodejs"
5+
6+
WORKDIR /usr/src/app
7+
8+
COPY ./package-lock.json ./
9+
COPY ./package.json ./
10+
COPY ./app.js ./
11+
12+
COPY ./src ./src
13+
COPY ./test ./test
14+
COPY ./custom ./custom
15+
16+
RUN find . -name 'package.json' -not -path '**/node_modules/*' -execdir npm ci \;
17+
18+
RUN npm prune --production
19+
20+
ENV NODE_ENV=production
21+
22+
CMD [ "npm", "start", "--silent" ]

0 commit comments

Comments
 (0)