Skip to content

Commit

Permalink
Merge branch 'main' of github.com:godaddy/timings
Browse files Browse the repository at this point in the history
  • Loading branch information
mverkerk-godaddy committed Apr 25, 2024
2 parents 5ea606f + cf37700 commit 7901780
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 110 deletions.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
56 changes: 56 additions & 0 deletions .github/actions/semantic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: semantic-release-node
description: 'perform semantic-release actions for node'

inputs:
publish:
description: 'tell semantic-release to publish or run in DRY-RUN mode (default)'
required: false
default: 'false'
add-summary:
description: 'Add output of semantic-release results to GITHUB_STEP_SUMMARY'
required: false
default: 'false'

outputs:
last_release_version:
description: 'version before semantic-release'
value: ${{ steps.release.outputs.last_release_version }}
new_release_version:
description: 'version after semantic-release'
value: ${{ steps.release.outputs.new_release_version }}
new_release_published:
description: 'whether semantic-release did (or would) publish a new version'
value: ${{ steps.release.outputs.new_release_published }}

runs:
using: composite
steps:
- name: run-release
id: release
shell: bash
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN || env.GH_TOKEN }}
NPM_TOKEN: ${{ env.NPM_TOKEN }}
run: |
echo "last_release_version=`cat package.json | jq -r .version`" >> $GITHUB_OUTPUT
if [[ '${{ inputs.publish }}' == 'true' ]]; then
npx semantic-release | tee release.output;
else
npx semantic-release --dry-run --no-ci --branches ${{ github.ref_name }} | tee release.output;
fi
echo "new_release_published=`if (grep -q 'The next release version is' release.output); then echo true; else echo false; fi`" >> $GITHUB_OUTPUT
echo "new_release_version=`grep 'The next release version is' release.output | sed -E 's/.* ([[:digit:].]+)$/\1/'`" >> $GITHUB_OUTPUT
- name: Update job summary after semantic-release
if: ${{ inputs.add-summary == 'true' }}
shell: bash
run: |
if [ '${{ steps.release.outputs.new_release_published }}' == 'true' ]; then
echo - A new release ${{ inputs.publish == 'true' && 'was' || 'will be' }} published! >> $GITHUB_STEP_SUMMARY
echo - Last Release: **${{ steps.release.outputs.last_release_version }}** >> $GITHUB_STEP_SUMMARY
echo - New Release: **${{ steps.release.outputs.new_release_version }}** >> $GITHUB_STEP_SUMMARY
else
echo - No new Release! The current release is: **${{ steps.release.outputs.last_release_version }}** >> $GITHUB_STEP_SUMMARY
fi
38 changes: 38 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Pull Request

To help us get this pull request reviewed and merged quickly, please be sure to include the following items:

* [ ] Tests (if applicable)
* [ ] Documentation (if applicable)
* [ ] Changelog entry
* [ ] A full explanation here in the PR description of the work done

## PR Type
What kind of change does this PR introduce?

* [ ] Bugfix
* [ ] Feature
* [ ] Code style update (formatting, local variables)
* [ ] Refactoring (no functional changes, no api changes)
* [ ] Build related changes
* [ ] CI related changes
* [ ] Documentation content changes
* [ ] Tests
* [ ] Other

## Backward Compatibility

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?

* [ ] Yes (backward compatible)
* [ ] No (breaking changes)


## Issue Linking
<!--
KEYWORD #ISSUE-NUMBER
[closes|fixes|resolves] #
-->

## What's new?
-
66 changes: 28 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,72 +11,62 @@ on:
- completed

jobs:
build:
deploy:
runs-on: ubuntu-latest

outputs:
release-outputs: ${{ steps.release.outputs }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install, build, and run tests
id: npm_ci
run: |
npm ci
uses: actions/checkout@v3

# Run release
- name: semantic-release [DRY-RUN]
- name: Semantic Release [PUBLISH]
uses: ./.github/actions/semantic
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
id: release
run: |
echo "lastRelease=`cat package.json | jq -r .version`" >> $GITHUB_OUTPUT
npx semantic-release | tee release.output;
echo "hasRelease=`if (grep -q 'The next release version is' release.output); then echo true; else echo false; fi`" >> $GITHUB_OUTPUT
echo "nextRelease=`grep 'The next release version is' release.output | sed -E 's/.* ([[:digit:].]+)$/\1/'`" >> $GITHUB_OUTPUT
- name: Update job summary after semantic-release
run: |
if [ '${{ steps.release.outputs.hasRelease }}' == 'true' ]; then
echo - A new release was be published! >> $GITHUB_STEP_SUMMARY
echo - Last Release: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY
echo - Next Release: **${{ steps.release.outputs.nextRelease }}** >> $GITHUB_STEP_SUMMARY
else
echo - No release was published! The current release is: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY
fi
with:
publish: true
add-summary: true

- name: Set up Docker Buildx
if: steps.release.outputs.hasRelease == 'true'
if: steps.release.outputs.new_release_published == 'true'
id: buildx
uses: docker/setup-buildx-action@master
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
if: steps.release.outputs.hasRelease == 'true'
if: steps.release.outputs.new_release_published == 'true'
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
if: steps.release.outputs.hasRelease == 'true'
uses: docker/login-action@v1
if: steps.release.outputs.new_release_published == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker Build and Push
if: steps.release.outputs.hasRelease == 'true'
if: steps.release.outputs.new_release_published == 'true'
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: |
godaddy/timings:latest
godaddy/timings:${{ steps.release.outputs.nextRelease }}
godaddy/timings:${{ steps.release.outputs.new_release_version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
run: |
echo ${{ steps.docker_build.outputs.digest }}
echo Docker image was published sucessfully! >> $GITHUB_STEP_SUMMARY
echo - Image ID: **${{ steps.docker_build.outputs.imageid }}** >> $GITHUB_STEP_SUMMARY
echo - digest: **${{ steps.docker_build.outputs.digest }}** >> $GITHUB_STEP_SUMMARY
echo - metadata: **${{ steps.docker_build.outputs.metadata }}** >> $GITHUB_STEP_SUMMARY
52 changes: 18 additions & 34 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,43 @@

name: Timings CI - test

'on':
on:
push:
branches:
- "**"

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.x, 19.x, 20.x]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.1.4
uses: actions/checkout@v3

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install, build, and run tests
id: npm_test

- name: Install node modules and run tests
run: |
npm ci
npm ci --ignore-scripts
npm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
file: coverage/cobertura-coverage.xml
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
fail_ci_if_error: false

# Run release after testing!
- name: semantic-release [DRY-RUN]
- name: Semantic Release [DRY-RUN]
if: ${{ matrix.node-version == '20.x' }}
uses: ./.github/actions/semantic
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
id: release
run: |
echo "lastRelease=`cat package.json | jq -r .version`" >> $GITHUB_OUTPUT
npx semantic-release --dry-run --no-ci --branches ${{ github.ref_name }} | tee release.output;
echo "hasRelease=`if (grep -q 'The next release version is' release.output); then echo true; else echo false; fi`" >> $GITHUB_OUTPUT
echo "nextRelease=`grep 'The next release version is' release.output | sed -E 's/.* ([[:digit:].]+)$/\1/'`" >> $GITHUB_OUTPUT
- name: Update job summary after semantic-release
run: |
if [ '${{ steps.release.outputs.hasRelease }}' == 'true' ]; then
echo - A new release will be published! >> $GITHUB_STEP_SUMMARY
echo - Last Release: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY
echo - Next Release: **${{ steps.release.outputs.nextRelease }}** >> $GITHUB_STEP_SUMMARY
else
echo - No new Release! The current release is: **${{ steps.release.outputs.lastRelease }}** >> $GITHUB_STEP_SUMMARY
fi
with:
publish: false
add-summary: true
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ WORKDIR /src

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

# Docker base image is already NODE_ENV=production
RUN cd /src
RUN npm install
RUN npm ci --only=prod --ignore-scripts

# Add source files
COPY . /src/
Expand Down
6 changes: 3 additions & 3 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"env": {
"ES_PROTOCOL": "http",
"ES_HOST": "",
"ES_HOST": "127.0.0.1",
"ES_PORT": 9200,
"ES_TIMEOUT": 5000,
"ES_USER": "",
"ES_PASS": "",
"ES_SSL_CERT": "",
"ES_SSL_KEY": "",
"KB_HOST": "",
"KB_PORT": 5601,
"KB_HOST": "127.0.0.1",
"KB_PORT": 5601,
"KB_INDEX": "",
"HTTP_PORT": 80
},
Expand Down
Loading

0 comments on commit 7901780

Please sign in to comment.