Skip to content

Commit

Permalink
General housekeeping (#54)
Browse files Browse the repository at this point in the history
* Update readme
* Change test names / directories
* Update development.md guide

NOTE: No actual changes to testing code were made. Changes to workflow
files are mostly for readability of files and also of the checks as
displayed on PRs.
  • Loading branch information
nstogner authored Jan 16, 2024
1 parent 8c38144 commit d4896cf
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 146 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create and publish a Docker image
name: Build and Push

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
Expand All @@ -8,44 +8,59 @@ on:
tags:
- "v*.*.*"
paths-ignore:
- 'README.md'
- "README.md"
pull_request:

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
# Defines two custom environment variables for the workflow.
# These are used for the Container registry domain, and a name
# for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: substratusai/lingo

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
# There is a single job in this workflow.
# It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
container:
runs-on: ubuntu-latest

# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#

steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- if: github.event_name == 'push'
name: Log in to the Container registry

# Uses the `docker/login-action` action to log in to the Container registry registry
# using the account and password that will publish the packages. Once published, the
# packages are scoped to the account defined here.
- name: Log in to the Container registry
if: github.event_name == 'push'
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.

# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about)
# to extract tags and labels that will be applied to the specified image. The `id` "meta"
# allows the output of this step to be referenced in a subsequent step. The `images` value
# provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image

# This step uses the `docker/build-push-action` action to build the image, based on your
# repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located
# in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)"
# in the README of the `docker/build-push-action` repository. It uses the `tags` and `labels`
# parameters to tag and label the image with the output from the "meta" step.
- name: Build and push container image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/integration-tests.yml

This file was deleted.

25 changes: 17 additions & 8 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,43 @@ run-name: Load tests by @${{ github.actor }}
on: workflow_dispatch

jobs:
perf-tests:
k6:
runs-on: ubuntu-latest

permissions:
contents: "read"
id-token: "write"

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

- name: Authenticate with GCP
uses: "google-github-actions/auth@v1"
with:
workload_identity_provider: "projects/819220466562/locations/global/workloadIdentityPools/github/providers/my-repo"
service_account: "[email protected]"
- name: "Set up Cloud SDK"

- name: Set up cloud SDK
uses: "google-github-actions/setup-gcloud@v1"
- id: "get-credentials"

- name: Get credentials
uses: "google-github-actions/get-gke-credentials@v1"
with:
cluster_name: "lingo-dev"
location: "us-central1"
- id: "get-pods"

- name: Get pods
run: "kubectl get pods"
- id: "install-skaffold"

- name: Install skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
chmod +x skaffold
sudo mv skaffold /usr/local/bin
- id: "configure-docker"
- name: Configure docker
run: gcloud auth configure-docker -q us-central1-docker.pkg.dev
- id: "run-tests"

- name: Run tests
run: "./tests/load/test.sh"
34 changes: 0 additions & 34 deletions .github/workflows/system-test-kind.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Tests
run-name: Run tests by @${{ github.actor }}

on:
push:
branches:
- main
pull_request:

jobs:
unit-and-integration:
runs-on: ubuntu-latest

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

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ">=1.21.0"

- name: Run unit tests
run: make test-unit

- name: Run integration tests
run: make test-integration

e2e:
runs-on: ubuntu-latest

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

- name: Install kind
run: |
# For AMD64 / x86_64
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
# For ARM64
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-arm64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Install skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
chmod +x skaffold
sudo mv skaffold /usr/local/bin
- name: Run e2e tests
run: make test-e2e
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
ENVTEST_K8S_VERSION = 1.27.1

.PHONY: test
test: test-unit

.PHONY: test-all
test-all: test-race test-integration
test: test-unit test-race test-integration test-e2e

.PHONY: test-unit
test-unit:
go test -mod=readonly ./pkg/...

.PHONY: test-race
test-race:
go test -mod=readonly -race ./pkg/...

.PHONY: test-integration
test-integration: envtest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./tests/integration -v

.PHONY: test-e2e
test-e2e:
./tests/e2e/test.sh

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
Expand Down
Loading

0 comments on commit d4896cf

Please sign in to comment.