-
Notifications
You must be signed in to change notification settings - Fork 61
166 lines (162 loc) · 5.63 KB
/
lbox-develop.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
163
164
165
166
name: LBox Develop
on:
push:
branches: [develop]
pull_request:
branches: [develop]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
jobs:
path-filter:
runs-on: ubuntu-latest
outputs:
lbox: ${{ steps.filter.outputs.lbox }}
test-matrix: ${{ steps.matrix.outputs.test-matrix }}
package-matrix: ${{ steps.matrix.outputs.publish-matrix }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: dorny/paths-filter@v3
id: filter
with:
list-files: 'json'
filters: |
lbox:
- 'libs/lbox*/**'
- id: matrix
uses: ./.github/actions/lbox-matrix
with:
files-changed: ${{ steps.filter.outputs.lbox_files }}
build:
needs: ['path-filter']
if: ${{ needs.path-filter.outputs.lbox == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.path-filter.outputs.test-matrix) }}
concurrency:
group: lbox-staging-${{ matrix.python-version }}-${{ matrix.package }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
ref: ${{ github.head_ref }}
- uses: ./.github/actions/python-package-shared-setup
with:
rye-version: ${{ vars.RYE_VERSION }}
python-version: ${{ matrix.python-version }}
- name: Format
run: rye format --check -v -p ${{ matrix.package }}
- name: Linting
run: rye lint -v -p ${{ matrix.package }}
- name: Unit
working-directory: libs/${{ matrix.package }}
run: rye run unit
- name: Integration
working-directory: libs/${{ matrix.package }}
env:
LABELBOX_TEST_API_KEY: ${{ secrets[matrix.api-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
LABELBOX_TEST_ENVIRON: 'staging'
run: rye run integration
test-pypi:
runs-on: ubuntu-latest
needs: ['build', 'path-filter']
if: ${{ needs.path-filter.outputs.lbox == 'true' }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.path-filter.outputs.package-matrix) }}
environment:
name: Test-PyPI-${{ matrix.package }}
url: 'https://test.pypi.org/p/${{ matrix.package }}'
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: ./.github/actions/python-package-shared-setup
with:
rye-version: ${{ vars.RYE_VERSION }}
python-version: '3.9'
- name: Create build
id: create-build
working-directory: libs/${{ matrix.package }}
run: |
VERSION=$(date +"%Y.%m.%d.%H.%M")
echo "pip install --index-url https://test.pypi.org/simple/ --extra-index-url=https://pypi.org/simple/ ${{ matrix.package }}@$VERSION" >> "$GITHUB_STEP_SUMMARY"
rye version "$VERSION"
rye run toml set --toml-path pyproject.toml project.name ${{ matrix.package }}
rye build
- name: Publish package distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
repository-url: https://test.pypi.org/legacy/
test-container:
runs-on: ubuntu-latest
needs: ['build', 'path-filter']
if: ${{ needs.path-filter.outputs.lbox == 'true' }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.path-filter.outputs.package-matrix) }}
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (Develop)
if: github.event_name == 'push'
uses: docker/build-push-action@v5
with:
context: .
file: ./libs/${{ matrix.package }}/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
push: true
platforms: |
linux/amd64
linux/arm64
tags: |
ghcr.io/labelbox/${{ matrix.package }}:develop
ghcr.io/labelbox/${{ matrix.package }}:${{ github.sha }}
- name: Build and push (Develop) Output
if: github.event_name == 'push'
run: |
echo "ghcr.io/labelbox/${{ matrix.package }}:develop" >> "$GITHUB_STEP_SUMMARY"
echo "ghcr.io/labelbox/${{ matrix.package }}:${{ github.sha }}" >> "$GITHUB_STEP_SUMMARY"
- name: Build and push (Pull Request)
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
file: ./libs/${{ matrix.package }}/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
push: true
platforms: |
linux/amd64
linux/arm64
tags: |
ghcr.io/labelbox/${{ matrix.package }}:${{ github.sha }}
- name: Build and push (Pull Request) Output
if: github.event_name == 'pull_request'
run: |
echo "ghcr.io/labelbox/${{ matrix.package }}:${{ github.sha }}" >> "$GITHUB_STEP_SUMMARY"