Skip to content

Commit 3086848

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

File tree

7 files changed

+75
-32
lines changed

7 files changed

+75
-32
lines changed

.github/workflows/build.yaml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Login to Docker Hub
20+
uses: docker/login-action@v3
21+
if: github.event_name != 'pull_request'
22+
with:
23+
username: ${{ vars.DOCKERHUB_USERNAME }}
24+
password: ${{ secrets.DOCKERHUB_TOKEN }}
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: stable
30+
31+
- name: Build and run tests
32+
run: |
33+
go install ./...
34+
go test -short -v ./...
35+
_script/run-e2e.sh read
36+
37+
- name: Set up QEMU
38+
uses: docker/setup-qemu-action@v3
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Docker meta
44+
id: meta
45+
uses: docker/metadata-action@v5
46+
with:
47+
images: |
48+
docker.io/${{ github.repository }}
49+
tags: |
50+
type=edge
51+
type=ref,event=branch
52+
type=semver,pattern={{version}}
53+
type=semver,pattern={{major}}.{{minor}}
54+
type=semver,pattern={{major}}
55+
type=sha
56+
57+
- name: Build and push
58+
uses: docker/build-push-action@v6
59+
with:
60+
platforms: linux/amd64,linux/arm64
61+
push: ${{ github.event_name != 'pull_request' }}
62+
tags: ${{ steps.meta.outputs.tags }}
63+
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)