Skip to content

Commit

Permalink
Merge pull request #275 from sourcenetwork/master-merge-release-0.2.1
Browse files Browse the repository at this point in the history
Release 0.2.1
  • Loading branch information
jsimnz authored Mar 6, 2022
2 parents 3b7ff1c + 6f2ef1c commit e4328e0
Show file tree
Hide file tree
Showing 141 changed files with 4,511 additions and 1,913 deletions.
11 changes: 7 additions & 4 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ options:
commit_groups:
title_maps:
feat: Features
fix: Bug fixes
fix: Fixes
tools: Tooling
docs: Documentation
perf: Performance
refactor: Refactoring
ci: Continous integration
docs: Documentation
test: Testing
ci: Continuous integration
sort_by: Custom
title_order:
- feat
- fix
- tools
- docs
- test
- perf
- refactor
- test
- ci
- chore
header:
Expand All @@ -38,4 +40,5 @@ options:
- Subject
notes:
keywords:
- BREAKING CHANGES
- BREAKING CHANGE
37 changes: 34 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,41 @@ jobs:
- run:
name: Run tests
command: |
DEFRA_BADGER_MEMORY=true
DEFRA_BADGER_FILE=true
DEFRA_MAP=true
mkdir -p /tmp/test-reports
gotestsum --junitfile /tmp/test-reports/unit-tests.xml -- ./... -race
environment:
DEFRA_BADGER_MEMORY: true
DEFRA_BADGER_FILE: true
DEFRA_MAP: true
- store_test_results:
path: /tmp/test-reports
change_detection:
working_directory: ~/repo
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: circleci/golang:1.17.5
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: make deps
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: |
mkdir -p /tmp/test-reports
gotestsum --junitfile /tmp/test-reports/unit-tests.xml -- ./... -p 1
environment:
DEFRA_DETECT_DATABASE_CHANGES: true
- store_test_results:
path: /tmp/test-reports

Expand All @@ -43,3 +73,4 @@ workflows:
# Inside the workflow, you define the jobs you want to run.
jobs:
- build
- change_detection
77 changes: 0 additions & 77 deletions .github/workflows/benchmark-ec2-runner.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/golangci-lint.yml

This file was deleted.

155 changes: 155 additions & 0 deletions .github/workflows/lint-then-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Lint and then Benchmark


on:
pull_request:

push:
tags:
- v*
branches:
- master
- develop


## These are the permissions for the lint check job.
permissions:
# Allow read access to pull request (Required for the `only-new-issues` option.)
pull-requests: read
contents: read


jobs:


# ========================================================= Step-1: Run the lint check.
golangci:
name: Lint Check
strategy:
matrix:
go-version: [1.17.5]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Check out code into the directory
uses: actions/checkout@v2

- name: Run the golangci-lint
uses: golangci/golangci-lint-action@v2

with:
# Required: the version of golangci-lint is required.
# Note: The version should not pick the patch version as the latest patch
# version is what will always be used.
version: v1.43

# Optional: working directory, useful for monorepos or if we wanted to run this
# on a non-root directory.
# working-directory: ./

# Optional: golangci-lint command line arguments.
# Note: we can set `--issues-exit-code=0` if we want a successcode always,
# indicating that the linter ran successfully (weather or not linter errors
# exist or not doesn't matter). But the good think is that the annotations
# will still show up. I think this can be useful if we don't want the pipeline
# to stop just because we had some linter errors.
args: --issues-exit-code=1 --config .golangci.sourceinc.yaml

# Optional: we can set the below to `true` if we only want to see newly
# introduced linter errors, however I found that in practive that option is a
# bit gimmicky, as it passes the linter check despite having new linter errors
# in some cases. So we opt in for all annotations of linter errors to show up,
# this is actually nicer because we suppress our linter errors manually
# anyways so there shouldn't be any linter errors anyways. The enforces us to
# always have a clean lint state.
only-new-issues: false


# ================== Step-2: Start the runner and get it registered as a github runner.
start-runner:
name: Start self-hosted EC2 runner
needs: golangci # only run if the linter check passed
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}

steps:

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.REPO_SCOPE_PAT }}
ec2-image-id: ${{ secrets.EC2_IMAGE_ID }}
ec2-instance-type: t3.xlarge
subnet-id: ${{ secrets.SUBNET_ID }}
security-group-id: ${{ secrets.SECURITY_GROUP_ID }}
## iam-role-name: my-role-name # optional, requires additional permissions
## aws-resource-tags: > # optional, requires additional permissions
## [
## {"Key": "Name", "Value": "ec2-github-runner"},
## {"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
## ]


# ============================Step-3: Run the benchmarks on the runner we just started.
benchmark-ec2-runner:
name: Run the benchmarks on the started EC2 runner
needs:
- golangci # only run if the linter check passed.
- start-runner # required to start the main job when the runner is ready
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner

env:
# This is also the same directory as `$GITHUB_WORKSPACE/..`
HOME: /actions-runner/_work
GOPATH: /actions-runner/_work/go

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Start Running the bechmarks
run: make test:bench


# =============================== Step-4: Stop the runner once the benchmarks have ran.
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- golangci # only run if the linter check passed.
- start-runner # required to get output from the start-runner job
- benchmark-ec2-runner # required to wait when the main job is done
runs-on: ubuntu-latest

# Stop the runner even if an error happened in the previous jobs. Also ensure that
# if the EC2 runner was actually started, only then we stop it.
if: ${{ always() && (needs.start-runner.result == 'success') }}

steps:

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.REPO_SCOPE_PAT }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
Loading

0 comments on commit e4328e0

Please sign in to comment.