Skip to content

Commit 7901780

Browse files
Merge branch 'main' of github.com:godaddy/timings
2 parents 5ea606f + cf37700 commit 7901780

14 files changed

+287
-110
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Additional context**
32+
Add any other context about the problem here.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/actions/semantic/action.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: semantic-release-node
2+
description: 'perform semantic-release actions for node'
3+
4+
inputs:
5+
publish:
6+
description: 'tell semantic-release to publish or run in DRY-RUN mode (default)'
7+
required: false
8+
default: 'false'
9+
add-summary:
10+
description: 'Add output of semantic-release results to GITHUB_STEP_SUMMARY'
11+
required: false
12+
default: 'false'
13+
14+
outputs:
15+
last_release_version:
16+
description: 'version before semantic-release'
17+
value: ${{ steps.release.outputs.last_release_version }}
18+
new_release_version:
19+
description: 'version after semantic-release'
20+
value: ${{ steps.release.outputs.new_release_version }}
21+
new_release_published:
22+
description: 'whether semantic-release did (or would) publish a new version'
23+
value: ${{ steps.release.outputs.new_release_published }}
24+
25+
runs:
26+
using: composite
27+
steps:
28+
- name: run-release
29+
id: release
30+
shell: bash
31+
env:
32+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN || env.GH_TOKEN }}
33+
NPM_TOKEN: ${{ env.NPM_TOKEN }}
34+
run: |
35+
echo "last_release_version=`cat package.json | jq -r .version`" >> $GITHUB_OUTPUT
36+
37+
if [[ '${{ inputs.publish }}' == 'true' ]]; then
38+
npx semantic-release | tee release.output;
39+
else
40+
npx semantic-release --dry-run --no-ci --branches ${{ github.ref_name }} | tee release.output;
41+
fi
42+
43+
echo "new_release_published=`if (grep -q 'The next release version is' release.output); then echo true; else echo false; fi`" >> $GITHUB_OUTPUT
44+
echo "new_release_version=`grep 'The next release version is' release.output | sed -E 's/.* ([[:digit:].]+)$/\1/'`" >> $GITHUB_OUTPUT
45+
46+
- name: Update job summary after semantic-release
47+
if: ${{ inputs.add-summary == 'true' }}
48+
shell: bash
49+
run: |
50+
if [ '${{ steps.release.outputs.new_release_published }}' == 'true' ]; then
51+
echo - A new release ${{ inputs.publish == 'true' && 'was' || 'will be' }} published! >> $GITHUB_STEP_SUMMARY
52+
echo - Last Release: **${{ steps.release.outputs.last_release_version }}** >> $GITHUB_STEP_SUMMARY
53+
echo - New Release: **${{ steps.release.outputs.new_release_version }}** >> $GITHUB_STEP_SUMMARY
54+
else
55+
echo - No new Release! The current release is: **${{ steps.release.outputs.last_release_version }}** >> $GITHUB_STEP_SUMMARY
56+
fi

.github/pull_request_template.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Pull Request
2+
3+
To help us get this pull request reviewed and merged quickly, please be sure to include the following items:
4+
5+
* [ ] Tests (if applicable)
6+
* [ ] Documentation (if applicable)
7+
* [ ] Changelog entry
8+
* [ ] A full explanation here in the PR description of the work done
9+
10+
## PR Type
11+
What kind of change does this PR introduce?
12+
13+
* [ ] Bugfix
14+
* [ ] Feature
15+
* [ ] Code style update (formatting, local variables)
16+
* [ ] Refactoring (no functional changes, no api changes)
17+
* [ ] Build related changes
18+
* [ ] CI related changes
19+
* [ ] Documentation content changes
20+
* [ ] Tests
21+
* [ ] Other
22+
23+
## Backward Compatibility
24+
25+
Is this change backward compatible with the most recently released version? Does it introduce changes which might change the user experience in any way? Does it alter the API in any way?
26+
27+
* [ ] Yes (backward compatible)
28+
* [ ] No (breaking changes)
29+
30+
31+
## Issue Linking
32+
<!--
33+
KEYWORD #ISSUE-NUMBER
34+
[closes|fixes|resolves] #
35+
-->
36+
37+
## What's new?
38+
-

.github/workflows/release.yml

+28-38
Original file line numberDiff line numberDiff line change
@@ -11,72 +11,62 @@ on:
1111
- completed
1212

1313
jobs:
14-
build:
14+
deploy:
1515
runs-on: ubuntu-latest
16-
16+
outputs:
17+
release-outputs: ${{ steps.release.outputs }}
1718
steps:
1819
- name: Checkout
19-
uses: actions/checkout@v2
20-
- name: Install, build, and run tests
21-
id: npm_ci
22-
run: |
23-
npm ci
20+
uses: actions/checkout@v3
2421

25-
# Run release
26-
- name: semantic-release [DRY-RUN]
22+
- name: Semantic Release [PUBLISH]
23+
uses: ./.github/actions/semantic
24+
id: release
2725
env:
2826
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2927
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30-
id: release
31-
run: |
32-
echo "lastRelease=`cat package.json | jq -r .version`" >> $GITHUB_OUTPUT
33-
34-
npx semantic-release | tee release.output;
35-
36-
echo "hasRelease=`if (grep -q 'The next release version is' release.output); then echo true; else echo false; fi`" >> $GITHUB_OUTPUT
37-
echo "nextRelease=`grep 'The next release version is' release.output | sed -E 's/.* ([[:digit:].]+)$/\1/'`" >> $GITHUB_OUTPUT
38-
39-
- name: Update job summary after semantic-release
40-
run: |
41-
if [ '${{ steps.release.outputs.hasRelease }}' == 'true' ]; then
42-
echo - A new release was be published! >> $GITHUB_STEP_SUMMARY
43-
echo - Last Release: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY
44-
echo - Next Release: **${{ steps.release.outputs.nextRelease }}** >> $GITHUB_STEP_SUMMARY
45-
else
46-
echo - No release was published! The current release is: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY
47-
fi
28+
with:
29+
publish: true
30+
add-summary: true
4831

4932
- name: Set up Docker Buildx
50-
if: steps.release.outputs.hasRelease == 'true'
33+
if: steps.release.outputs.new_release_published == 'true'
5134
id: buildx
52-
uses: docker/setup-buildx-action@master
35+
uses: docker/setup-buildx-action@v2
36+
5337
- name: Cache Docker layers
54-
if: steps.release.outputs.hasRelease == 'true'
38+
if: steps.release.outputs.new_release_published == 'true'
5539
uses: actions/cache@v2
5640
with:
5741
path: /tmp/.buildx-cache
5842
key: ${{ runner.os }}-buildx-${{ github.sha }}
5943
restore-keys: |
6044
${{ runner.os }}-buildx-
45+
6146
- name: Login to Docker Hub
62-
if: steps.release.outputs.hasRelease == 'true'
63-
uses: docker/login-action@v1
47+
if: steps.release.outputs.new_release_published == 'true'
48+
uses: docker/login-action@v2
6449
with:
6550
username: ${{ secrets.DOCKER_USERNAME }}
6651
password: ${{ secrets.DOCKER_PASSWORD }}
52+
6753
- name: Docker Build and Push
68-
if: steps.release.outputs.hasRelease == 'true'
54+
if: steps.release.outputs.new_release_published == 'true'
6955
id: docker_build
70-
uses: docker/build-push-action@v2
56+
uses: docker/build-push-action@v4
7157
with:
72-
context: .
73-
file: ./Dockerfile
7458
builder: ${{ steps.buildx.outputs.name }}
7559
push: true
7660
tags: |
7761
godaddy/timings:latest
78-
godaddy/timings:${{ steps.release.outputs.nextRelease }}
62+
godaddy/timings:${{ steps.release.outputs.new_release_version }}
7963
cache-from: type=local,src=/tmp/.buildx-cache
8064
cache-to: type=local,dest=/tmp/.buildx-cache
65+
8166
- name: Image digest
82-
run: echo ${{ steps.docker_build.outputs.digest }}
67+
run: |
68+
echo ${{ steps.docker_build.outputs.digest }}
69+
echo Docker image was published sucessfully! >> $GITHUB_STEP_SUMMARY
70+
echo - Image ID: **${{ steps.docker_build.outputs.imageid }}** >> $GITHUB_STEP_SUMMARY
71+
echo - digest: **${{ steps.docker_build.outputs.digest }}** >> $GITHUB_STEP_SUMMARY
72+
echo - metadata: **${{ steps.docker_build.outputs.metadata }}** >> $GITHUB_STEP_SUMMARY

.github/workflows/test.yml

+18-34
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,43 @@
33

44
name: Timings CI - test
55

6-
'on':
6+
on:
77
push:
8-
branches:
9-
- "**"
108

119
jobs:
1210
test:
1311
runs-on: ubuntu-latest
1412
strategy:
13+
fail-fast: false
1514
matrix:
1615
node-version: [18.x, 19.x, 20.x]
1716
steps:
1817
- name: Checkout
19-
uses: actions/checkout@v2
20-
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/[email protected]
18+
uses: actions/checkout@v3
19+
20+
- name: Setup Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
2222
with:
2323
node-version: ${{ matrix.node-version }}
24-
- name: Install, build, and run tests
25-
id: npm_test
24+
25+
- name: Install node modules and run tests
2626
run: |
27-
npm ci
27+
npm ci --ignore-scripts
2828
npm test
29+
2930
- name: Upload coverage to Codecov
30-
uses: codecov/codecov-action@v1
31+
uses: codecov/codecov-action@v3
3132
with:
3233
file: coverage/cobertura-coverage.xml
33-
- name: Extract branch name
34-
shell: bash
35-
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
36-
id: extract_branch
34+
fail_ci_if_error: false
3735

38-
# Run release after testing!
39-
- name: semantic-release [DRY-RUN]
36+
- name: Semantic Release [DRY-RUN]
4037
if: ${{ matrix.node-version == '20.x' }}
38+
uses: ./.github/actions/semantic
39+
id: release
4140
env:
4241
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4342
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44-
id: release
45-
run: |
46-
echo "lastRelease=`cat package.json | jq -r .version`" >> $GITHUB_OUTPUT
47-
48-
npx semantic-release --dry-run --no-ci --branches ${{ github.ref_name }} | tee release.output;
49-
50-
echo "hasRelease=`if (grep -q 'The next release version is' release.output); then echo true; else echo false; fi`" >> $GITHUB_OUTPUT
51-
echo "nextRelease=`grep 'The next release version is' release.output | sed -E 's/.* ([[:digit:].]+)$/\1/'`" >> $GITHUB_OUTPUT
52-
53-
- name: Update job summary after semantic-release
54-
run: |
55-
if [ '${{ steps.release.outputs.hasRelease }}' == 'true' ]; then
56-
echo - A new release will be published! >> $GITHUB_STEP_SUMMARY
57-
echo - Last Release: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY
58-
echo - Next Release: **${{ steps.release.outputs.nextRelease }}** >> $GITHUB_STEP_SUMMARY
59-
else
60-
echo - No new Release! The current release is: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY
61-
fi
43+
with:
44+
publish: false
45+
add-summary: true

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ WORKDIR /src
1010

1111
# Install dependencies first, add code later: docker is caching by layers
1212
COPY package.json /src/package.json
13+
COPY package-lock.json /src/package-lock.json
1314

1415
# Docker base image is already NODE_ENV=production
1516
RUN cd /src
16-
RUN npm install
17+
RUN npm ci --only=prod --ignore-scripts
1718

1819
# Add source files
1920
COPY . /src/

config/default.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"env": {
33
"ES_PROTOCOL": "http",
4-
"ES_HOST": "",
4+
"ES_HOST": "127.0.0.1",
55
"ES_PORT": 9200,
66
"ES_TIMEOUT": 5000,
77
"ES_USER": "",
88
"ES_PASS": "",
99
"ES_SSL_CERT": "",
1010
"ES_SSL_KEY": "",
11-
"KB_HOST": "",
12-
"KB_PORT": 5601,
11+
"KB_HOST": "127.0.0.1",
12+
"KB_PORT": 5601,
1313
"KB_INDEX": "",
1414
"HTTP_PORT": 80
1515
},

0 commit comments

Comments
 (0)