Skip to content

Commit

Permalink
Merge pull request #5 from eds-collabora/eds/actions_cleanup4
Browse files Browse the repository at this point in the history
Eds/actions cleanup4
  • Loading branch information
eds-collabora authored Aug 6, 2021
2 parents c66a48d + 41f3ec7 commit 5e0a565
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 31 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
29 changes: 0 additions & 29 deletions .github/workflows/build-test.yaml

This file was deleted.

200 changes: 200 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: Build, test and deploy

on:
push:
branches: [ master ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ master ]
workflow_dispatch:
~

env:
DOCKERHUB_TAG: edscollabora/debos
GITHUB_TAG: ghcr.io/${{ github.repository_owner }}/debos
TEST_TAG: ${{ github.repository }}

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v2

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1

- name: Use cache
uses: actions/cache@v2
with:
path: /tmp/.build-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
push: false
file: docker/Dockerfile
cache-from: type=local,src=/tmp/.build-cache
cache-to: type=local,dest=/tmp/.build-cache,mode=max

unit-test:
name: Run unit tests
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v2

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1

- name: Use cache
uses: actions/cache@v2
with:
path: /tmp/.build-cache
key: ${{ runner.os }}-docker-${{ github.sha }}

- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: ${{ env.TEST_TAG }}:builder
file: docker/Dockerfile
cache-from: type=local,src=/tmp/.build-cache
load: true
target: builder

- name: Run unit tests
run: |
docker-compose -f docker/unit-tests.test.yml \
up --exit-code-from=sut
env:
IMAGE: ${{ env.TEST_TAG }}:builder

recipe-test:
name: Run recipe tests
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v2

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1

- name: Use cache
uses: actions/cache@v2
with:
path: /tmp/.build-cache
key: ${{ runner.os }}-docker-${{ github.sha }}

- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: ${{ env.TEST_TAG }}
file: docker/Dockerfile
cache-from: type=local,src=/tmp/.build-cache
load: true

- name: Run test recipes on host
run: |
docker-compose -f docker/recipes.test.yml \
up --exit-code-from=sut
env:
IMAGE: ${{ env.TEST_TAG }}

uml-test:
name: Run UML tests
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v2

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1

- name: Use cache
uses: actions/cache@v2
with:
path: /tmp/.build-cache
key: ${{ runner.os }}-docker-${{ github.sha }}

- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: ${{ env.TEST_TAG }}
file: docker/Dockerfile
cache-from: type=local,src=/tmp/.build-cache
load: true

- name: Run test recipes using UML backend
run: |
docker-compose -f docker/recipes-test-uml.yml \
up --exit-code-from=sut
env:
IMAGE: ${{ env.TEST_TAG }}

publish:
name: Publish
needs:
- unit-test
- recipe-test
- uml-test
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKERHUB_TAG }},${{ env.GITHUB_TAG }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1

- name: Use cache
uses: actions/cache@v2
with:
path: /tmp/.build-cache
key: ${{ runner.os }}-docker-${{ github.sha }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: docker/Dockerfile
cache-from: type=local,src=/tmp/.build-cache
3 changes: 2 additions & 1 deletion docker/recipes-test-uml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ services:
build:
context: ..
dockerfile: docker/Dockerfile
target: runner
image:
"${IMAGE}"
volumes:
- type: bind
source: ../tests
Expand Down
3 changes: 2 additions & 1 deletion docker/recipes.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ services:
build:
context: ..
dockerfile: docker/Dockerfile
target: runner
image:
"${IMAGE}"
volumes:
- type: bind
source: ../tests
Expand Down
2 changes: 2 additions & 0 deletions docker/unit-tests.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ services:
context: ..
dockerfile: docker/Dockerfile
target: builder
image:
"${IMAGE}"
working_dir: /usr/local/go/src/github.com/go-debos/debos
command: go test -v ./...

0 comments on commit 5e0a565

Please sign in to comment.