-
Notifications
You must be signed in to change notification settings - Fork 4
132 lines (111 loc) · 3.43 KB
/
test-and-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Test and Push
on:
push:
branches:
- main
paths:
- 'datacube_alchemist/**'
- 'tests/**'
- '.github/workflows/push-and-test.yml'
- 'Dockerfile'
- 'requirements.txt'
- 'constraints.txt'
- 'setup.py'
pull_request:
branches:
- main
paths:
- 'datacube_alchemist/**'
- 'tests/**'
- '.github/workflows/push-and-test.yml'
- 'Dockerfile'
- 'requirements.txt'
- 'constraints.txt'
- 'setup.py'
release:
types: [created, edited]
env:
IMAGE_NAME: opendatacube/datacube-alchemist
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: rickstaa/action-black@v1
with:
black_args: "--check datacube_alchemist"
- name: Build the docker container
run: |
docker-compose build
- name: Bring up the docker container
run: |
docker-compose up -d
sleep 5
docker-compose exec -T alchemist datacube system init
- name: Run tests
run: |
docker-compose exec -T alchemist pytest --cov=./datacube_alchemist --cov-report=xml tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
- name: Integration tests
run: |
docker-compose exec -T alchemist bash ./tests/integration_tests.sh
push:
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Build and Push for main branch
# Docker
- name: Get git commit hash for push to main
if: github.event_name != 'release'
run: |
git fetch --all --tags
echo "GITHASH=$(git describe --tags)" >> $GITHUB_ENV
- name: Build and Push unstable Docker Image for push to main
uses: whoan/[email protected]
if: github.event_name != 'release'
with:
image_name: ${{ env.IMAGE_NAME }}
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
image_tag: latest,${{ env.GITHASH }}
# Build and Push for release
# Python
- name: Build the package
if: github.event_name == 'release'
run: |
pip install build
python -m build
- name: Deploy packages to DEA Packages
if: github.event_name == 'release'
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks
env:
AWS_S3_BUCKET: "datacube-core-deployment"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "ap-southeast-2" # optional: defaults to us-east-1
SOURCE_DIR: "dist" # optional: defaults to entire repository
DEST_DIR: "datacube-alchemist"
# Docker
- name: Get tag for this build if it exists
if: github.event_name == 'release'
run: |
echo "RELEASE=${GITHUB_REF/refs\/tags\/}" >> $GITHUB_ENV
- name: Build and Push semver tagged Docker Image for Release
uses: whoan/[email protected]
if: github.event_name == 'release'
with:
image_name: ${{ env.IMAGE_NAME }}
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
image_tag: ${{ env.RELEASE }}