Skip to content

Commit

Permalink
feat: create action for testing go (#1)
Browse files Browse the repository at this point in the history
* feat: create action for testing go

* chore: 1.21

* feat: add docker build and push as gha

* fix: replace keelhq with datagravity

* feat: add docker build and node github actions

* fix: run in correct folder

* fix: only use node 16 for now

* fix: swap keel-hq for datagrativty-ai

* fix: no test on npm

* feat: run for multiple versions of go
  • Loading branch information
knechtionscoding authored Feb 9, 2024
1 parent 10425a7 commit 7736610
Show file tree
Hide file tree
Showing 113 changed files with 653 additions and 389 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: default

workspace:
base: /go
path: src/github.com/keel-hq/keel
path: src/github.com/datagravity-ai/keel

steps:
- name: unit-test
Expand Down
99 changes: 99 additions & 0 deletions .github/workflows/docker-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Docker-UI

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '35 20 * * *'
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: keel-ui


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image - Standard
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
99 changes: 99 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '35 20 * * *'
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image - Standard
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
31 changes: 31 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:

build:
strategy:
matrix:
go-version: [1.21,1.22]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Build
run: make build

- name: Test
run: make test
34 changes: 34 additions & 0 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'ui/package-lock.json'
- run: npm ci
working-directory: ui
- run: npm run build --if-present
working-directory: ui
# - run: npm test
# working-directory: ui
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.21.3
COPY . /go/src/github.com/keel-hq/keel
WORKDIR /go/src/github.com/keel-hq/keel
COPY . /go/src/github.com/datagravity-ai/keel
WORKDIR /go/src/github.com/datagravity-ai/keel
RUN make install

FROM node:16.20.2-alpine
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM golang:1.14.2
COPY . /go/src/github.com/keel-hq/keel
WORKDIR /go/src/github.com/keel-hq/keel
COPY . /go/src/github.com/datagravity-ai/keel
WORKDIR /go/src/github.com/datagravity-ai/keel
RUN make build

FROM debian:latest
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

COPY --from=0 /go/src/github.com/keel-hq/keel/cmd/keel/keel /bin/keel
COPY --from=0 /go/src/github.com/datagravity-ai/keel/cmd/keel/keel /bin/keel
ENTRYPOINT ["/bin/keel"]

EXPOSE 9300
46 changes: 23 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ GIT_REVISION = $(shell git rev-parse --short HEAD)
VERSION ?= $(shell git describe --tags --abbrev=0)

LDFLAGS += -linkmode external -extldflags -static
LDFLAGS += -X github.com/keel-hq/keel/version.Version=$(VERSION)
LDFLAGS += -X github.com/keel-hq/keel/version.Revision=$(GIT_REVISION)
LDFLAGS += -X github.com/keel-hq/keel/version.BuildDate=$(JOBDATE)
LDFLAGS += -X github.com/datagravity-ai/keel/version.Version=$(VERSION)
LDFLAGS += -X github.com/datagravity-ai/keel/version.Revision=$(GIT_REVISION)
LDFLAGS += -X github.com/datagravity-ai/keel/version.BuildDate=$(JOBDATE)

ARMFLAGS += -a -v
ARMFLAGS += -X github.com/keel-hq/keel/version.Version=$(VERSION)
ARMFLAGS += -X github.com/keel-hq/keel/version.Revision=$(GIT_REVISION)
ARMFLAGS += -X github.com/keel-hq/keel/version.BuildDate=$(JOBDATE)
ARMFLAGS += -X github.com/datagravity-ai/keel/version.Version=$(VERSION)
ARMFLAGS += -X github.com/datagravity-ai/keel/version.Revision=$(GIT_REVISION)
ARMFLAGS += -X github.com/datagravity-ai/keel/version.BuildDate=$(JOBDATE)

.PHONY: release

Expand All @@ -34,20 +34,20 @@ build-arm:
# cd cmd/keel && env GOARCH=arm64 GOOS=linux go build -ldflags="$(ARMFLAGS)" -o release/keel-linux-aarc64

armhf-latest:
docker build -t keelhq/keel-arm:latest -f Dockerfile.armhf .
docker push keelhq/keel-arm:latest
docker build -t datagravity-ai/keel-arm:latest -f Dockerfile.armhf .
docker push datagravity-ai/keel-arm:latest

aarch64-latest:
docker build -t keelhq/keel-aarch64:latest -f Dockerfile.aarch64 .
docker push keelhq/keel-aarch64:latest
docker build -t datagravity-ai/keel-aarch64:latest -f Dockerfile.aarch64 .
docker push datagravity-ai/keel-aarch64:latest

armhf:
docker build -t keelhq/keel-arm:$(VERSION) -f Dockerfile.armhf .
# docker push keelhq/keel-arm:$(VERSION)
docker build -t datagravity-ai/keel-arm:$(VERSION) -f Dockerfile.armhf .
# docker push datagravity-ai/keel-arm:$(VERSION)

aarch64:
docker build -t keelhq/keel-aarch64:$(VERSION) -f Dockerfile.aarch64 .
docker push keelhq/keel-aarch64:$(VERSION)
docker build -t datagravity-ai/keel-aarch64:$(VERSION) -f Dockerfile.aarch64 .
docker push datagravity-ai/keel-aarch64:$(VERSION)

arm: build-arm fetch-certs armhf aarch64

Expand All @@ -61,24 +61,24 @@ build:

install:
@echo "++ Installing keel"
# CGO_ENABLED=0 GOOS=linux go install -ldflags "$(LDFLAGS)" github.com/keel-hq/keel/cmd/keel
GOOS=linux go install -ldflags "$(LDFLAGS)" github.com/keel-hq/keel/cmd/keel
# CGO_ENABLED=0 GOOS=linux go install -ldflags "$(LDFLAGS)" github.com/datagravity-ai/keel/cmd/keel
GOOS=linux go install -ldflags "$(LDFLAGS)" github.com/datagravity-ai/keel/cmd/keel

image:
docker build -t keelhq/keel:alpha -f Dockerfile .
docker build -t datagravity-ai/keel:alpha -f Dockerfile .

image-debian:
docker build -t keelhq/keel:alpha -f Dockerfile.debian .
docker build -t datagravity-ai/keel:alpha -f Dockerfile.debian .

alpha: image
@echo "++ Pushing keel alpha"
docker push keelhq/keel:alpha
docker push datagravity-ai/keel:alpha

e2e: install
cd tests && go test

run:
go install github.com/keel-hq/keel/cmd/keel
go install github.com/datagravity-ai/keel/cmd/keel
keel --no-incluster --ui-dir ui/dist

lint-ui:
Expand All @@ -89,8 +89,8 @@ run-ui:
cd ui && yarn run serve

build-ui:
docker build -t keelhq/keel:ui -f Dockerfile .
docker push keelhq/keel:ui
docker build -t datagravity-ai/keel:ui -f Dockerfile .
docker push datagravity-ai/keel:ui

run-debug: install
DEBUG=true keel --no-incluster
DEBUG=true keel --no-incluster
Loading

0 comments on commit 7736610

Please sign in to comment.