generated from stactools-packages/template
-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (139 loc) · 4.6 KB
/
continuous-integration.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
133
134
135
136
137
138
139
140
141
142
name: CI
on:
push:
branches:
- main
pull_request:
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: ${{ github.repository }}
jobs:
codecov:
name: codecov
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Execute linters and test suites
run: ./docker/cibuild
- name: Upload All coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: false
python-matrix:
name: python-matrix
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- name: Set up conda cache
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ hashFiles('**/environment.yml') }}
restore-keys: ${{ runner.os }}-conda-
- name: Set up pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg', '**/requirements-dev.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Set up Conda with Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Update Conda's environemnt
run: conda env update -f environment.yml -n test
- name: Execute linters and test suites
run: ./scripts/cibuild
docker:
name: docker
needs:
- codecov
- python-matrix
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.x"
-
name: Checkout
uses: actions/checkout@v2
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run rename script if in the template repo
run: |
if [[ "$GITHUB_REPOSITORY" == */template ]]; then
scripts/rename
fi
- name: Source build args
run: |
source ./docker_env
STACTOOLS_VERSION=$(python scripts/stactools-version.py)
echo "stactools_version=$STACTOOLS_VERSION" >> $GITHUB_ENV
echo "docker_workdir=$DOCKER_WORKDIR" >> $GITHUB_ENV
echo "docker_namespace_package_dir=$DOCKER_NAMESPACE_PACKAGE_DIR" >> $GITHUB_ENV
-
name: Docker meta main
id: meta-main
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
-
name: Build and push main
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
build-args: |
STACTOOLS_VERSION=${{ env.stactools_version }}
DOCKER_WORKDIR=${{ env.docker_workdir }}
DOCKER_NAMESPACE_PACKAGE_DIR=${{ env.docker_namespace_package_dir }}
# Don't try to push if the event is a PR from a fork
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta-main.outputs.tags }}
labels: ${{ steps.meta-main.outputs.labels }}
-
name: Docker meta dev
id: meta-dev
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
flavor: |
suffix=-dev
tags: |
type=ref,event=branch
type=ref,event=pr
-
name: Build and push dev
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile-dev
build-args: |
STACTOOLS_VERSION=${{ env.stactools_version }}
DOCKER_WORKDIR=${{ env.docker_workdir }}
DOCKER_NAMESPACE_PACKAGE_DIR=${{ env.docker_namespace_package_dir }}
# Don't try to push if the event is a PR from a fork
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta-dev.outputs.tags }}
labels: ${{ steps.meta-dev.outputs.labels }}