-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflows: Update docker and test workflows (#53)
- Loading branch information
1 parent
0648265
commit 5ad4b61
Showing
5 changed files
with
109 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ on: | |
pull_request: | ||
push: | ||
branches: | ||
- "main" | ||
- main | ||
- dev | ||
tags: | ||
- "v*" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Publish images to dockerhub | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
docker: | ||
name: Build and publish docker images | ||
permissions: | ||
packages: write | ||
contents: read | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.CI_DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.CI_DOCKERHUB_TOKEN }} | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ github.token }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
livepeer/data | ||
ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=schedule,pattern={{date 'YYYYMMDDHHmmss'}} | ||
type=ref,event=branch | ||
type=ref,event=tag | ||
type=ref,event=pr | ||
type=sha | ||
type=sha,format=long | ||
type=semver,pattern={{version}},prefix=v | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=semver,pattern={{major}}.{{minor}},prefix=v | ||
type=raw,value=${{ github.event.pull_request.head.ref }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
platforms: linux/amd64, linux/arm64 | ||
push: true | ||
build-args: | | ||
version=${{ github.ref_type == 'tag' && github.ref_name || github.sha }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: notify livepeer-infra | ||
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
name: Test project | ||
name: Trigger test suite for the project | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
test: | ||
name: Trigger tests | ||
name: Run tests with coverage reporting | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Set up go | ||
id: go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.17 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
# Check https://github.com/livepeer/go-livepeer/pull/1891 | ||
# for ref value discussion | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Restore cache | ||
uses: actions/cache@v3 | ||
- name: Set up go | ||
id: go | ||
uses: actions/setup-go@v3 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
go-version: 1.17 | ||
cache: true | ||
cache-dependency-path: go.sum | ||
|
||
- name: Download dependencies | ||
if: ${{ steps.go.outputs.cache-hit != 'true' }} | ||
run: go mod download | ||
|
||
- name: Run test suite | ||
run: make test | ||
- name: Run tests with coverage | ||
run: go test ./... -v --race --covermode=atomic --coverprofile=coverage.out | ||
|
||
- name: Upload coverage reports | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: ./coverage.out | ||
name: ${{ github.event.repository.name }} | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
FROM golang:1.16-alpine as builder | ||
FROM golang:1.16-alpine as builder | ||
|
||
RUN apk add --update make | ||
RUN apk add --no-cache --update make | ||
|
||
WORKDIR /app | ||
WORKDIR /app | ||
|
||
ENV GOFLAGS "-mod=readonly" | ||
ENV GOFLAGS "-mod=readonly" | ||
|
||
COPY go.mod go.sum ./ | ||
COPY go.mod go.sum ./ | ||
|
||
RUN go mod download | ||
RUN go mod download | ||
|
||
ARG version | ||
RUN echo $version | ||
ARG version | ||
|
||
COPY . . | ||
RUN echo $version | ||
|
||
RUN make "version=$version" | ||
COPY . . | ||
|
||
FROM alpine | ||
RUN make "version=$version" | ||
|
||
WORKDIR /app | ||
FROM alpine:latest | ||
|
||
COPY --from=builder /app/build/* . | ||
WORKDIR /app | ||
|
||
COPY --from=builder /app/build/* /usr/local/bin/ |