forked from USF-COT/glider_utils
-
Notifications
You must be signed in to change notification settings - Fork 11
162 lines (132 loc) · 3.98 KB
/
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Push
on:
push:
workflow_dispatch:
pull_request:
env:
BUILDX_CACHE: /tmp/.buildx-cache
CACHE_KEY: gutils-buildx-
jobs:
pre-commit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.0
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9"]
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3
- name: Setup Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-file: false
- name: Python ${{ matrix.python-version }}
shell: bash -l {0}
run: |
micromamba create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt --channel conda-forge
micromamba activate TEST
pip install -e . --no-deps --force-reinstall
- name: Debug conda
shell: bash -l {0}
run: |
micromamba activate TEST
micromamba info --all
micromamba list
- name: Tests
shell: bash -l {0}
run: |
micromamba activate TEST
pytest --disable-warnings -m "not long and not watch"
pypi-build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
shell: bash
- name: Install build tools
run: |
python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine
shell: bash
- name: Build binary wheel
run: python -m build --sdist --wheel . --outdir dist
- name: CheckFiles
run: |
ls dist
shell: bash
- name: Test wheels
run: |
cd dist && python -m pip install gutils*.whl
python -m twine check *
shell: bash
docker-build:
name: Build and test Docker Image
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${ BUILDX_CACHE }
key: ${ CACHE_KEY }${{ github.sha }}
restore-keys: |
${ CACHE_KEY }
- name: Login to Docker Hub
uses: docker/login-action@v1
continue-on-error: true
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
push: false
tags: axiom/gutils:latest
cache-from: type=local,src=${ BUILDX_CACHE }
cache-to: type=local,dest=${ BUILDX_CACHE }
outputs: type=docker
- name: Run tests from the Docker image
run: docker run axiom/gutils:latest pytest -m "not long and not watch"
docker-push:
name: Push latest image to Docker Hub
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: docker-build
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && github.repository == 'SECOORA/GUTILS'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${ BUILDX_CACHE }
key: ${ CACHE_KEY }${{ github.sha }}
restore-keys: |
${ CACHE_KEY }
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push latest image to Docker Hub if on master or main branch of the repo
uses: docker/build-push-action@v2
with:
push: true
tags: axiom/gutils:latest
cache-from: type=local,src=${ BUILDX_CACHE }
cache-to: type=local,dest=${ BUILDX_CACHE }