Skip to content

Commit

Permalink
tools: Migrate from CircleCi to GitHub Actions (#679)
Browse files Browse the repository at this point in the history
- Resolves #570 

- Description:
	* Moves all our CircleCi workflows to GitHub Actions (Change Detection, Test Runs).
	* Change detection will only run in [PRs] or [pushes to tags, master, or develop].
	* Change detection for GitHub Action Workflow needed explicit private and public ssh keys (generated and added the corresponding keys to secret section, and deploy key sections), there is an authentication step that takes care of the SSH authentication for that workflow.
	* Added a new Workflow to build defradb binary and call `defradb start` on it to ensure the start up command doesn't crash.
	* Removed CircleCi config file validation tool.
  • Loading branch information
shahzadlone authored Aug 3, 2022
1 parent 0bc2a07 commit 3973c2d
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 117 deletions.
100 changes: 0 additions & 100 deletions .circleci/config.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .github/workflows/code-test-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Code Test Coverage
name: Code Test Coverage Workflow

on: [push]

jobs:
code-test-coverage:
name: Code test coverage job

runs-on: ubuntu-latest

steps:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/detect-change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Detect Change Workflow

on:
pull_request:

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

jobs:
detect-change:
name: Detect change job

runs-on: ubuntu-latest

steps:
- name: Checkout code into the directory
uses: actions/checkout@v3

- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.17"
check-latest: true

- name: Build dependencies
run: |
make deps:modules
make deps:test
# We need SSH Authorization because change detection needs use `ls-remote` like:
# git ls-remote [email protected]:sourcenetwork/defradb.git refs/heads/develop
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Run detection for changes
run: make test:changes

## Uncomment to enable ability to SSH into the runner.
#- name: Setup upterm ssh session for debugging
# uses: lhotari/action-upterm@v1
# with:
# limit-access-to-actor: true
# limit-access-to-users: shahzadlone
8 changes: 5 additions & 3 deletions .github/workflows/lint-then-benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint and then Benchmark
name: Lint Then Benchmark Workflow

on:
pull_request:
Expand All @@ -23,7 +23,8 @@ env:
jobs:
# ========================================================= Step-1: Run the lint check.
golangci:
name: Lint Check
name: Lint check job

strategy:
matrix:
os: [ubuntu-latest]
Expand Down Expand Up @@ -75,6 +76,7 @@ jobs:
# This job acts like a switch to simplify our ci control flow later on.
decide-benchmark-type:
name: Decide which benchmarks to run based on flags

strategy:
matrix:
os: [ubuntu-latest]
Expand Down Expand Up @@ -112,7 +114,7 @@ jobs:

# ================== Step-3: Start the runner and get it registered as a github runner.
start-runner:
name: Start self-hosted EC2 runner
name: Start self-hosted EC2 runner job

needs:
- golangci # only run if the linter check passed.
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run Tests Workflow

on: [push]

jobs:
run-tests:
name: Run tests job

runs-on: ubuntu-latest

steps:
- name: Checkout code into the directory
uses: actions/checkout@v3

- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.17"
check-latest: true

- name: Build dependencies
run: |
make deps:modules
make deps:test
- name: Run the tests, showing name of each test
run: make test:names
50 changes: 50 additions & 0 deletions .github/workflows/start-binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Start Binary Workflow

on:
pull_request:

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

jobs:
start-binary:
name: Start binary job

runs-on: ubuntu-latest

steps:

- name: Checkout code into the directory
uses: actions/checkout@v3

- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.17"
check-latest: true

- name: Build modules
run: make deps:modules

- name: Build binary
run: make build

- name: Attempt to start binary
run: |
./build/defradb start &
sleep 5
- name: Check if binary is still running
run: |
FOUND=$(pgrep -c "defradb");
echo "Process(es) we found = [${FOUND}]";
if [[ ${FOUND} == 0 ]]; then
echo "DefraDB start command failed.";
exit 1;
else
echo "DefraDB running.";
fi
30 changes: 17 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ start:
@$(MAKE) build
./build/defradb start

.PHONY: dev\:start
dev\:start:
@$(MAKE) build
DEFRA_ENV=dev ./build/defradb start

.PHONY: client\:dump
client\:dump:
./build/defradb client dump
Expand Down Expand Up @@ -84,14 +79,19 @@ deps\:chglog:
deps\:modules:
go mod download

.PHONY: deps\:ci
deps\:ci:
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | DESTDIR=${HOME}/bin bash

.PHONY: deps
deps:
@$(MAKE) deps:lint && $(MAKE) deps:coverage && $(MAKE) deps:bench && $(MAKE) deps:chglog && \
$(MAKE) deps:modules && $(MAKE) deps:ci && $(MAKE) deps:test
@$(MAKE) deps:modules && \
$(MAKE) deps:bench && \
$(MAKE) deps:chglog && \
$(MAKE) deps:coverage && \
$(MAKE) deps:lint && \
$(MAKE) deps:test

.PHONY: dev\:start
dev\:start:
@$(MAKE) build
DEFRA_ENV=dev ./build/defradb start

.PHONY: tidy
tidy:
Expand All @@ -114,9 +114,13 @@ test:
test\:go:
go test ./... -race -shuffle=on

.PHONY: test\:names
test\:names:
gotestsum --format testname -- ./... -race -shuffle=on

.PHONY: test\:verbose
test\:verbose:
gotestsum --format testname --junitfile /tmp/defradb-dev/test.xml -- ./... -race -shuffle=on
gotestsum --format standard-verbose -- ./... -race -shuffle=on

.PHONY: test\:watch
test\:watch:
Expand Down Expand Up @@ -160,7 +164,7 @@ test\:coverage-html:

.PHONY: test\:changes
test\:changes:
env DEFRA_DETECT_DATABASE_CHANGES=true gotestsum --junitfile /tmp/defradb-dev/changes.xml -- ./... -shuffle=on -p 1
env DEFRA_DETECT_DATABASE_CHANGES=true gotestsum -- ./... -shuffle=on -p 1

.PHONY: validate\:codecov
validate\:codecov:
Expand Down

0 comments on commit 3973c2d

Please sign in to comment.