-
Notifications
You must be signed in to change notification settings - Fork 54
138 lines (132 loc) · 5.44 KB
/
build.yml
File metadata and controls
138 lines (132 loc) · 5.44 KB
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
name: Build
on: [push, pull_request, workflow_dispatch]
env:
BUILD_TYPE: Release
DATA_ROOT: ${{ github.workspace }}/data
DATA_BRANCH: master
GENERATOR_PLATFORM:
jobs:
source-package:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install git-archive-all
run: python -m pip install git-archive-all
- name: Generate source archives with submodules
shell: bash
run: |
TAG="${GITHUB_REF#refs/tags/}"
echo "TAG=$TAG" >> $GITHUB_ENV
git-archive-all --prefix="grok-${TAG}/" "source-full.tar.gz"
git-archive-all --prefix="grok-${TAG}/" "source-full.zip"
- name: Upload source archives to release
uses: softprops/action-gh-release@v1
with:
files: |
source-full.tar.gz
source-full.zip
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
shared_libs_flag: [ON, OFF]
fail-fast: false # Allow all matrix jobs to run, even if one fails
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: true # Recursively clone submodules
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install pytest
run: pip install pytest
- name: Delete workflow runs
if: startsWith(matrix.os, 'ubuntu') && matrix.shared_libs_flag == 'ON'
uses: Mattraks/delete-workflow-runs@v2.0.6
- name: ubuntu-dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
#echo DATA_BRANCH=linux-release >> $GITHUB_ENV
sudo apt install libpsl-dev swig
- name: macos-dependencies
if: startsWith(matrix.os, 'macos')
run: |
#echo DATA_BRANCH=osx >> $GITHUB_ENV
brew install libpsl libssh2 swig
# Add macOS-specific dependencies if needed
- name: windows-dependencies
if: startsWith(matrix.os, 'windows')
run: |
echo "C:/Users/runneradmin/AppData/Roaming/Python/Python39/Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo $env:GITHUB_PATH
$generator= "-DCMAKE_GENERATOR_PLATFORM=x64"
echo "Generator: ${generator}"
echo "GENERATOR_PLATFORM=$generator" >> $env:GITHUB_ENV
C:\vcpkg\vcpkg.exe install libpsl:x64-windows
echo "CMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" >> $env:GITHUB_ENV
choco install swig -y
refreshenv
- name: dependencies
run: |
cmake -E make_directory ${{ github.workspace }}/build
git clone --depth=1 --branch=${{ env.DATA_BRANCH }} https://github.com/GrokImageCompression/grok-test-data.git ${{ env.DATA_ROOT }}
- name: configure cmake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{ github.workspace }}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: |
if [[ "${{ matrix.os }}" != "ubuntu-latest" ]]; then
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=${{ matrix.shared_libs_flag }} -DBUILD_TESTING:BOOL=ON -DGRK_DATA_ROOT=$DATA_ROOT -DGRK_ENABLE_LIBCURL=OFF $GENERATOR_PLATFORM
else
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=${{ matrix.shared_libs_flag }} -DBUILD_TESTING:BOOL=ON -DGRK_DATA_ROOT=$DATA_ROOT -DGRK_ENABLE_LIBCURL=ON $GENERATOR_PLATFORM
fi
- name: build
working-directory: ${{ github.workspace }}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: test
working-directory: ${{ github.workspace }}/build
shell: bash
run: |
ctest --output-on-failure -C $BUILD_TYPE --output-junit test-results-${{ matrix.os }}-${{ matrix.shared_libs_flag }}.xml
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-shared_${{ matrix.shared_libs_flag }}
path: |
${{ github.workspace }}/build/test-results-${{ matrix.os }}-${{ matrix.shared_libs_flag }}.xml
${{ github.workspace }}/build/Testing/Temporary/LastTest.log
- name: package
if: ${{ matrix.shared_libs_flag == 'ON' }}
working-directory: ${{ github.workspace }}/build
shell: bash
run: |
cmake -Wno-dev -D CPACK_GENERATOR:STRING=ZIP -D CPACK_PACKAGE_FILE_NAME:STRING=grok-${{ matrix.os }} .
cmake --build . --config $BUILD_TYPE --target package
7z x grok-${{ matrix.os }}.zip
- name: publish
if: ${{ matrix.shared_libs_flag == 'ON' }}
uses: actions/upload-artifact@v4
with:
name: grok-${{ matrix.os }}
path: ${{ github.workspace }}/build/grok-${{ matrix.os }}
- name: Upload binaries to release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
files: build/grok-${{ matrix.os }}.zip