Skip to content

Commit

Permalink
Split GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
peanutfun committed Jan 13, 2023
1 parent 9bf1054 commit b9e9c25
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: build

on:
push:
branches:

jobs:
docker-build:
uses: ./.github/workflows/docker.yml
secrets: inherit

unit-tests:
needs: docker-build
uses: ./.github/workflows/test.yml
with:
test-type: unit-test

data-api-tests:
uses: ./.github/workflows/test.yml
with:
test-type: data-test
38 changes: 38 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: docker

on:
workflow_call:
secrets:
DOCKER_USERNAME:
required: true
DOCKER_ACCESS_TOKEN:
required: true

env:
DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }}

jobs:
build-image:
runs-on: ubuntu-latest
steps:
-
name: Checkout Repo
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: peanutfunn/climada_env:${{ github.ref_name }}
4 changes: 0 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: ci

on:
push:
branches:

env:
DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }}

Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: test

on:
workflow_call:
inputs:
test-type:
required: true
type: string

jobs:
unit-test:
if: inputs.test-type == 'unit-test'
runs-on: ubuntu-latest
container:
image: peanutfunn/climada_env:${{ github.ref_name }}
options: --user root
steps:
-
name: Checkout Repo
uses: actions/checkout@v3
-
name: Run Unit Tests
run: |
micromamba run python -m coverage run tests_runner.py unit
data-test:
if: inputs.test-type == 'data-test'
runs-on: ubuntu-latest
container:
image: peanutfunn/climada_env:${{ github.ref_name }}
options: --user root
steps:
-
name: Checkout Repo
uses: actions/checkout@v3
-
name: Run Unit Tests
run: |
micromamba run python test_data_api.py

0 comments on commit b9e9c25

Please sign in to comment.