Skip to content

Commit 7f5ccbd

Browse files
authored
Migrate to github actions (#191)
1 parent 3f22c4e commit 7f5ccbd

File tree

8 files changed

+81
-39
lines changed

8 files changed

+81
-39
lines changed

.github/workflows/build.yaml

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

.travis.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

Dockerfile

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# syntax=docker/dockerfile:1.4
21
# Copyright 2021 Adevinta
32

4-
FROM --platform=$BUILDPLATFORM golang:1.23-alpine3.19 as builder
3+
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
54

65
WORKDIR /app
76

@@ -13,35 +12,28 @@ COPY . .
1312

1413
ARG TARGETOS TARGETARCH
1514

16-
WORKDIR /app/cmd/vulcan-scan-engine
17-
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build .
15+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build ./cmd/vulcan-scan-engine
1816

1917
FROM alpine:3.21
2018

2119
WORKDIR /flyway
2220

23-
RUN apk add --no-cache --update openjdk17-jre bash gettext
21+
RUN apk add --no-cache openjdk17-jre bash gettext
2422

2523
ARG FLYWAY_VERSION=10.10.0
2624

2725
RUN wget -q https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/${FLYWAY_VERSION}/flyway-commandline-${FLYWAY_VERSION}.tar.gz \
2826
&& tar -xzf flyway-commandline-${FLYWAY_VERSION}.tar.gz --strip 1 \
2927
&& rm flyway-commandline-${FLYWAY_VERSION}.tar.gz \
30-
&& find ./drivers/ -type f | grep -Ev '(postgres|jackson)' | xargs rm \
28+
&& find ./drivers/ -type f -not -name '*postgres*' -not -name '*jackson*' -delete \
3129
&& chown -R root:root . \
3230
&& ln -s /flyway/flyway /bin/flyway
3331

3432
WORKDIR /app
3533

36-
ARG BUILD_RFC3339="1970-01-01T00:00:00Z"
37-
ARG COMMIT="local"
38-
39-
ENV BUILD_RFC3339 "$BUILD_RFC3339"
40-
ENV COMMIT "$COMMIT"
41-
4234
COPY --link db/*.sql ./sql/
4335
COPY --link config.toml run.sh ./
4436

45-
COPY --from=builder --link /app/cmd/vulcan-scan-engine/vulcan-scan-engine .
37+
COPY --from=builder --link /app/vulcan-scan-engine .
4638

4739
CMD [ "./run.sh" ]

db/clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
# Copyright 2021 Adevinta
44

5-
docker run --net=host --rm -v "$PWD":/flyway/sql flyway/flyway:"${FLYWAY_VERSION:-10}-alpine" \
5+
docker run -q --net=host --rm -v "$PWD":/flyway/sql flyway/flyway:"${FLYWAY_VERSION:-10}-alpine" \
66
-user=vulcan -password=vulcan -url=jdbc:postgresql://localhost:5434/scan-enginedb -baselineOnMigrate=true -cleanDisabled=false clean

db/migrate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
# Copyright 2021 Adevinta
44

5-
docker run --net=host --rm -v "$PWD":/flyway/sql flyway/flyway:"${FLYWAY_VERSION:-10}-alpine" \
5+
docker run -q --net=host --rm -v "$PWD":/flyway/sql flyway/flyway:"${FLYWAY_VERSION:-10}-alpine" \
66
-user=vulcan -password=vulcan -url=jdbc:postgresql://localhost:5434/scan-enginedb -baselineOnMigrate=true migrate

db/postgres-start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Copyright 2021 Adevinta
44

5-
docker run --name vulcan-scan-enginedb -p 5434:5434 -e POSTGRES_PASSWORD=vulcan -e POSTGRES_USER=vulcan -e POSTGRES_DB=scan-enginedb -e PGPORT=5434 -d --rm postgres:13.3-alpine
5+
docker run -q --name vulcan-scan-enginedb -p 5434:5434 -e POSTGRES_PASSWORD=vulcan -e POSTGRES_USER=vulcan -e POSTGRES_DB=scan-enginedb -e PGPORT=5434 -d --rm postgres:13.3-alpine
66

77
sleep 5
88

db/repair_migrations.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
# Copyright 2021 Adevinta
44

5-
docker run --net=host --rm -v "$PWD":/flyway/sql flyway/flyway:"${FLYWAY_VERSION:-10}-alpine" \
5+
docker run -q --net=host --rm -v "$PWD":/flyway/sql flyway/flyway:"${FLYWAY_VERSION:-10}-alpine" \
66
-user=vulcan -password=vulcan -url=jdbc:postgresql://localhost:5434/scan-enginedb -baselineOnMigrate=true repair

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/adevinta/vulcan-scan-engine
22

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

67
require (

0 commit comments

Comments
 (0)