Skip to content

Commit c6eafdb

Browse files
committed
Migrate to github actions
1 parent 74be774 commit c6eafdb

File tree

7 files changed

+79
-32
lines changed

7 files changed

+79
-32
lines changed

.github/workflows/build.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Go Build & Test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- '**'
8+
pull_request:
9+
workflow_dispatch:
10+
11+
jobs:
12+
build-and-test:
13+
runs-on: ubuntu-latest
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Login to Docker Hub
24+
uses: docker/login-action@v3
25+
if: github.event_name != 'pull_request'
26+
with:
27+
username: ${{ vars.DOCKERHUB_USERNAME }}
28+
password: ${{ secrets.DOCKERHUB_TOKEN }}
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version: stable
34+
35+
- name: Build and run tests
36+
run: |
37+
go install ./...
38+
go test -short -v ./...
39+
_script/run-e2e.sh read
40+
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Docker meta
48+
id: meta
49+
uses: docker/metadata-action@v5
50+
with:
51+
images: |
52+
docker.io/${{ github.repository }}
53+
tags: |
54+
type=edge
55+
type=ref,event=branch
56+
type=semver,pattern={{version}}
57+
type=semver,pattern={{major}}.{{minor}}
58+
type=semver,pattern={{major}}
59+
type=sha
60+
61+
- name: Build and push
62+
uses: docker/build-push-action@v6
63+
with:
64+
platforms: linux/amd64,linux/arm64
65+
push: ${{ github.event_name != 'pull_request' }}
66+
tags: ${{ steps.meta.outputs.tags }}
67+
labels: ${{ steps.meta.outputs.labels }}

.travis.yml

-17
This file was deleted.

Dockerfile

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
# Copyright 2020 Adevinta
22

3-
FROM golang:1.22-alpine3.18 as builder
3+
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
44

55
WORKDIR /app
66

7+
ARG TARGETOS TARGETARCH
8+
79
COPY go.mod .
810
COPY go.sum .
911

1012
RUN go mod download
1113

1214
COPY . .
1315

14-
RUN cd cmd/vulnerability-db-api/ && GOOS=linux GOARCH=amd64 go build . && cd -
16+
RUN cd cmd/vulnerability-db-api/ && GOOS=$TARGETOS GOARCH=$TARGETARCH go build . && cd -
1517

1618
FROM alpine:3.21
1719

1820
RUN apk add --no-cache --update bash gettext
1921

2022
WORKDIR /app
2123

22-
ARG BUILD_RFC3339="1970-01-01T00:00:00Z"
23-
ARG COMMIT="local"
24-
25-
ENV BUILD_RFC3339 "$BUILD_RFC3339"
26-
ENV COMMIT "$COMMIT"
27-
2824
COPY --from=builder /app/cmd/vulnerability-db-api/vulnerability-db-api .
2925

3026
COPY config.toml .

_resources/postgres-start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# Copyright 2020 Adevinta
44

5-
docker-compose up -d
5+
docker compose up -d

_resources/postgres-stop.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
# Copyright 2020 Adevinta
44

5-
docker-compose kill
6-
docker-compose rm -f
5+
docker compose kill
6+
docker compose rm -f

_script/run-e2e.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ case $ARG in
3434
esac
3535

3636
# Start postgress databases.
37-
docker-compose -f _resources/docker-compose-e2e.yml -p e2e up --quiet-pull -d $SERVICE
37+
docker compose -f _resources/docker-compose-e2e.yml -p e2e up --quiet-pull -d $SERVICE
3838

3939
# Set up schema for the test db.
4040
VDB=$(mktemp -d)
@@ -60,10 +60,10 @@ vulnerability-db-api -c $CONFIG_FILE &
6060

6161
# Run e2e tests.
6262
echo "RUNNING e2e tests"
63-
docker-compose -f _resources/docker-compose-e2e.yml -p "e2e" run e2e
63+
docker compose -f _resources/docker-compose-e2e.yml -p "e2e" run --quiet-pull e2e
6464

6565
# Clean up resurces.
6666
set +e
6767
pkill vulnerability-db-api
6868
set -e
69-
docker-compose -f _resources/docker-compose-e2e.yml -p "e2e" rm -s -f -v
69+
docker compose -f _resources/docker-compose-e2e.yml -p "e2e" rm -s -f -v

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/adevinta/vulnerability-db-api
22

3-
go 1.21.2
3+
go 1.23.0
4+
45
toolchain go1.24.1
56

67
require (

0 commit comments

Comments
 (0)