Skip to content

Commit

Permalink
all: basic project
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemtam committed Jul 27, 2023
1 parent f40ee6d commit b8b3861
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.20 as build

WORKDIR /go/src/app
COPY . .

RUN go mod download
RUN go vet -v
RUN go test -v

RUN CGO_ENABLED=0 go build -o /go/bin/app

FROM gcr.io/distroless/static-debian11

COPY --from=build /go/bin/app /

CMD ["/app"]
84 changes: 84 additions & 0 deletions .github/workflows/ci-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI (Go)
on:
push:
workflow_dispatch:
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Go linters
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=15m --verbose --enable whitespace,gocritic,goimports,revive
skip-pkg-cache: true
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run tests
run: |
go test -race ./...
integration-tests:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build
uses: docker/build-push-action@v2
with:
context: .
file: ./.github/workflows/Dockerfile
tags: local
load: true
- run: docker images
- name: sanity
uses: ./internal/action
with:
url: sqlite://file.db
docker:
runs-on: ubuntu-latest
needs: [golangci-lint, unit-tests, integration-tests]
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
file: ./.github/workflows/Dockerfile
tags: arigaio/atlas-deploy-action:latest
17 changes: 17 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'atlas-deploy-action'
description: 'Deploy your database schema migrations using Atlas'
branding:
icon: database
author: 'Ariga'
inputs:
url:
description: 'URL to target database (should be passed as a secret).'
required: true
cloud-token:
description: 'Token for using Atlas Cloud (should be passed as a secret).'
required: false
cloud-dir:
description: 'Name of the migration directory in the cloud'
runs:
using: 'docker'
image: 'docker://arigaio/atlas-deploy-action:latest'
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/ariga/atlas-deploy-action

go 1.20

require github.com/sethvargo/go-githubactions v1.1.0

require github.com/sethvargo/go-envconfig v0.9.0 // indirect
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/sethvargo/go-envconfig v0.9.0 h1:Q6FQ6hVEeTECULvkJZakq3dZMeBQ3JUpcKMfPQbKMDE=
github.com/sethvargo/go-envconfig v0.9.0/go.mod h1:Iz1Gy1Sf3T64TQlJSvee81qDhf7YIlt8GMUX6yyNFs0=
github.com/sethvargo/go-githubactions v1.1.0 h1:mg03w+b+/s5SMS298/2G6tHv8P0w0VhUFaqL1THIqzY=
github.com/sethvargo/go-githubactions v1.1.0/go.mod h1:qIboSF7yq2Qnaw2WXDsqCReM0Lo1gU4QXUWmhBC3pxE=
3 changes: 3 additions & 0 deletions internal/action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runs:
using: 'docker'
image: 'docker://local'
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

import "github.com/sethvargo/go-githubactions"

func main() {
act := githubactions.New()
act.Infof("Hello, world!")
}
7 changes: 7 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "testing"

func Test(t *testing.T) {
t.Skip("skipping")
}

0 comments on commit b8b3861

Please sign in to comment.