-
Notifications
You must be signed in to change notification settings - Fork 15
212 lines (176 loc) · 6.31 KB
/
build_and_test.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# This is a basic workflow to help you get started with Actions
name: Build, Test & Publush
# Controls when the action will run.
on:
# Triggers the workflow on all push or pull request events
push:
pull_request:
release:
types: [created]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
# added using https://github.com/step-security/secure-repo
permissions:
contents: read
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_and_test:
# The type of runner that the job will run on
runs-on: [self-hosted, linux, x64]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y bmake cmake
- name: Build with GNU Make
run: make clean all
- name: Test with GNU Make
run: make test
- name: Build with BSD Make
run: bmake clean all
- name: Test with BSD Make
run: bmake test
- name: Build with CMake
run: |
cmake -B build
make -C build clean all
- name: Test with CMake
run: bmake -C build test
build_and_test_python:
needs: build_and_test
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
compiler: ['gcc', 'clang']
os: [macos, ubuntu]
include:
- python-version: '3.10'
compiler: microsoft
os: windows
- python-version: '3.11'
compiler: microsoft
os: windows
- python-version: '3.12'
compiler: microsoft
os: windows
runs-on: ${{ matrix.os }}-latest
env:
COMPILER: ${{ matrix.compiler }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install -r python/requirements.txt
shell: bash
- name: build
run: CC=${COMPILER} python setup.py build sdist
shell: bash
- name: install
run: pip install dist/[Gg]722*.gz
shell: bash
- name: test
if: ${{ matrix.os != 'windows' }}
run: ./scripts/do-test.sh "python test.py"
shell: bash
- name: unit tests
run: python -m unittest discover tests '*.py'
shell: bash
publish_wheels:
needs: [build_and_test_python, build_in_docker]
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/G722
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install -r python/requirements.txt
- name: build
run: python setup.py build sdist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
build_in_docker:
needs: [build_and_test, build_and_test_python]
runs-on: ubuntu-latest
strategy:
matrix:
base_image: ['debian:sid-slim', 'debian:12-slim', 'ubuntu:latest']
env:
DOCKER_REPO: sippylabs/libg722
BASE_IMAGE: ${{ matrix.base_image }}
DOCKER_RW: ${{ ( github.repository == 'sippy/libg722' && github.event_name != 'pull_request' ) && 'true' || 'false' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,arm,riscv64,mips64le,ppc64le,s390x
- name: Log in to Docker Hub
if: ${{ env.DOCKER_RW }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set environments
run: |
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)"' | sort -u | paste -sd ','`"
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_ENV
OS_TAG="`echo ${BASE_IMAGE} | sed 's|:|_|g'`"
echo "OS_TAG=${OS_TAG}" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REPO }}
tags: |
type=schedule,suffix=-${{ env.OS_TAG}}
type=ref,event=branch,suffix=-${{ env.OS_TAG }}
type=ref,event=tag,suffix=-${{ env.OS_TAG }}
type=ref,event=pr,suffix=-${{ env.OS_TAG }}
type=raw,value=latest-${{ env.OS_TAG }},enable={{is_default_branch}}
type=sha,suffix=-${{ env.OS_TAG }}
- name: Build Docker image
uses: docker/build-push-action@v6
env:
CACHE_SPEC: "type=registry,ref=${{ env.DOCKER_REPO }}:${{ env.GIT_BRANCH }}-${{ env.OS_TAG}}-buildcache"
with:
context: .
file: ./docker/Dockerfile.build
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.DOCKER_RW }}
cache-from: ${{ env.CACHE_SPEC }}
cache-to: ${{ env.CACHE_SPEC }},mode=max