Skip to content

Commit

Permalink
ci: Add workflow to ensure deps build properly (#1078)
Browse files Browse the repository at this point in the history
- Resolves #1077
- Resolves #1075
- Resolves-Partially #1076 
- Updated to new PATv2 (in the secrets) and updated with the new PAT name `ONLY_DEFRADB_REPO_CI_PAT`.
- Add a new CI workflow to test our dependency-building steps are not broken (not required for PR to merge).
- Add the deploy script that was written for cloning defradb on the cloud infra.
- Added missing headers in workflow files.
  • Loading branch information
shahzadlone committed Apr 13, 2023
1 parent c435355 commit deb65e7
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 6 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Build Dependencies Workflow

on:
pull_request:

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

jobs:
build-dependencies:
name: Build dependencies 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.18"
check-latest: true

- name: Build all dependencies
run: make deps
10 changes: 10 additions & 0 deletions .github/workflows/code-test-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Copyright 2022 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Code Test Coverage Workflow

on: [push]
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/detect-change.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Copyright 2022 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Detect Change Workflow

on:
Expand Down
28 changes: 23 additions & 5 deletions .github/workflows/lint-then-benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Copyright 2022 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Lint Then Benchmark Workflow

on:
Expand All @@ -12,6 +22,14 @@ on:

## These are the permissions for the lint check job.
permissions:
# Must have a secret (`secrets.ONLY_DEFRADB_REPO_CI_PAT`) setup with the following permissions:
# - Actions: Read-Write
# - Administration: Read-Write
# - Pull Request: Read-Write
# - Contents: Read-Only
# - Metadata: Read-Only
# - Secrets: Read-Only

# Allow read access to pull request (Required for the `only-new-issues` option.)
pull-requests: read
contents: read
Expand Down Expand Up @@ -141,7 +159,7 @@ jobs:
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.REPO_SCOPE_PAT }}
github-token: ${{ secrets.ONLY_DEFRADB_REPO_CI_PAT }}
ec2-image-id: ${{ secrets.EC2_IMAGE_ID }}
ec2-instance-type: t3.xlarge
subnet-id: ${{ secrets.SUBNET_ID }}
Expand Down Expand Up @@ -220,15 +238,15 @@ jobs:
with:
branch: develop
workflow_id: lint-then-benchmark.yml
github_token: ${{ secrets.REPO_SCOPE_PAT }}
github_token: ${{ secrets.ONLY_DEFRADB_REPO_CI_PAT }}

- name: Download the latest benchmark artifact on develop
if: |
github.event_name == 'pull_request' &&
github.base_ref == 'develop'
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.REPO_SCOPE_PAT }}
github_token: ${{ secrets.ONLY_DEFRADB_REPO_CI_PAT }}
workflow: lint-then-benchmark.yml
branch: develop
name: bench-artifact-${{ steps.last_successful_upload_on_develop.outputs.commit_hash }}
Expand Down Expand Up @@ -260,7 +278,7 @@ jobs:
github.base_ref == 'develop'
uses: machine-learning-apps/pr-comment@master
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPE_PAT }}
GITHUB_TOKEN: ${{ secrets.ONLY_DEFRADB_REPO_CI_PAT }}
with:
path: pretty-comparison.md

Expand Down Expand Up @@ -295,6 +313,6 @@ jobs:
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.REPO_SCOPE_PAT }}
github-token: ${{ secrets.ONLY_DEFRADB_REPO_CI_PAT }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
10 changes: 10 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Copyright 2022 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Run Tests Workflow

on: [push]
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/start-binary.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Copyright 2022 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Start Binary Workflow

on:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/validate-title.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Copyright 2022 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Validate Title Workflow

on:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ client\:add-schema:

.PHONY: deps\:lint
deps\:lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.3

.PHONY: deps\:test
deps\:test:
Expand Down
36 changes: 36 additions & 0 deletions tools/scripts/deploy_defradb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Copyright 2023 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

# Pre-requirements:
# - GoLang
# - Git

# Usage: ./deploy_defradb.sh <PAT> <RELEASE_TAG_OR_COMMIT>
# Example: ./deploy_defradb.sh "v0.4.0" "github_pat_xyz"

COMMIT_TO_DEPLOY="$1";
READ_ONLY_DEFRADB_PAT="$2";
DEFRADB_GIT_REPO="github.com/sourcenetwork/defradb.git";

\git clone "https://git:${READ_ONLY_DEFRADB_PAT}@${DEFRADB_GIT_REPO}";

\cd ./defradb || { printf "\ncd into defradb failed.\n" && exit 2; };

\git checkout "${COMMIT_TO_DEPLOY}" || { printf "\nchecking out commit failed.\n" && exit 3; };

\make deps:modules || { printf "\nbuilding defradb dependencies failed.\n" && exit 4; };

\make install || { printf "\nfailure while installing defradb.\n" && exit 5; };

\defradb version || { printf "\ndefradb installed but not working properly.\n" && exit 6; };

printf "\ndefradb successfully installed.\n";

0 comments on commit deb65e7

Please sign in to comment.