-
Notifications
You must be signed in to change notification settings - Fork 1
180 lines (161 loc) · 6.73 KB
/
build.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
name: DeployTest
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
versionning:
name: Versionning
runs-on: ubuntu-latest
outputs:
version: ${{ steps.genver.outputs.version }}
release: ${{ steps.genver.outputs.release }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Generate Version
id: genver
run: |
VERSION=$(docker run --rm -v $(pwd):/repo codacy/git-version /bin/git-version --folder=/repo --release-branch=${{ github.ref_name }}-pre --dev-branch=main)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION : $VERSION"
RELEASE=$(docker run --rm -v $(pwd):/repo codacy/git-version /bin/git-version --folder=/repo --release-branch=${{ github.ref_name }} --dev-branch=main)
echo "release=$RELEASE" >> $GITHUB_OUTPUT
echo "RELEASE : $RELEASE"
echo "Version :" >> $GITHUB_STEP_SUMMARY
echo "$VERSION" >> $GITHUB_STEP_SUMMARY
echo "Release :" >> $GITHUB_STEP_SUMMARY
echo "$RELEASE" >> $GITHUB_STEP_SUMMARY
format:
name: Format C++
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Run clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check Diff
id: check-diff
run: |
git ls-files *.{c,h,hpp,cpp,cc} | xargs clang-format -style=file:.clang-format -i
DIFF="$(git diff --name-only)"
if [ -z "$DIFF" ]; then
echo "OK: Format is clean"
else
echo "Error: Format was not clean"
echo "List of files:"
echo "$DIFF"
git diff
exit 1
fi
- name: Generate patch
if: ${{ failure() && steps.check-diff.conclusion == 'failure' }}
run: |
git diff > patch-cpp.diff
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.check-diff.conclusion == 'failure' }}
with:
name: patch-cpp
path: ./patch-cpp.diff
build-cpp-packages:
name: Build C++ Packages
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dist: ["Alpine", "RedHat", "Ubuntu"]
needs: [versionning]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Install ArmoniK Dependencies
uses: aneoconsulting/ArmoniK.Action.Deploy/dependencies@main
with:
docker: true
terraform: true
k3s: true
aws: true
- name: Checkout Infra
uses: actions/checkout@v3
with:
repository: aneoconsulting/ArmoniK
path: infra
- name: Build C++ SDK
id: build
run: |
source ./tools/common.sh
export ARMONIK_SHARED_HOST_PATH=${{ github.workspace }}/infra/infrastructure/quick-deploy/localhost/all-in-one/data
export WORKER_IMG="dockerhubaneo/armonik-sdk-cpp-dynamicworker"
export CLIENT_IMG="dockerhubaneo/armonik-sdk-client-test"
export WORKER_TEST_IMG="dockerhubaneo/armonik-sdk-worker-test"
./tools/build-deploy-end2end.sh "${{ matrix.dist }}" "$WORKER_IMG" "${{ needs.versionning.outputs.version}}" "$ARMONIK_API_VERSION_DEFAULT" "$WORKER_TEST_IMG"
./tools/build-client.sh "$CLIENT_IMG" "${{ needs.versionning.outputs.version}}" "$API_VERSION"
export WORKER_VERSION="${{ needs.versionning.outputs.version}}-$(echo "${{ matrix.dist }}" | awk '{print tolower($0)}')"
docker save "$WORKER_IMG:$WORKER_VERSION" | sudo k3s ctr images import /dev/stdin
echo "worker_img=$WORKER_IMG" >> $GITHUB_OUTPUT
echo "worker_version=$WORKER_VERSION" >> $GITHUB_OUTPUT
echo "client_img=$CLIENT_IMG" >> $GITHUB_OUTPUT
echo "client_version=${{ needs.versionning.outputs.version}}" >> $GITHUB_OUTPUT
echo "worker_test_img=$WORKER_TEST_IMG" >> $GITHUB_OUTPUT
- name: Login Docker
run: echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} --password-stdin
- name: Override parameters tfvars
run: |
cat ${{ github.workspace }}/infra/versions.tfvars.json | jq --arg worker "${{ steps.build.outputs.worker_img }}" --arg version "${{ steps.build.outputs.worker_version }}" '.armonik_versions.samples=$version | .armonik_images.samples+=[$worker]' > .versions.tfvars.json
mv .versions.tfvars.json ${{ github.workspace }}/infra/versions.tfvars.json
- id: deploy
name: Deploy
uses: aneoconsulting/ArmoniK.Action.Deploy/deploy@main
with:
working-directory: ${{ github.workspace }}/infra
type: localhost
core-version: 0.20.5
- name: Run Client tests
timeout-minutes: 5
run: |
set -ex
kubectl set image deployment/compute-plane-default -n armonik worker-0=${{ steps.build.outputs.worker_img}}:${{ steps.build.outputs.worker_version }}
export CPIP=$(kubectl get svc control-plane -n armonik -o custom-columns="IP:.spec.clusterIP" --no-headers=true)
export CPPort=$(kubectl get svc control-plane -n armonik -o custom-columns="PORT:.spec.ports[*].port" --no-headers=true)
docker run --rm -t --network host -e Grpc__EndPoint=http://$CPIP:$CPPort -e WorkerLib__Version="${{ needs.versionning.outputs.version}}" "${{ steps.build.outputs.client_img}}:${{ needs.versionning.outputs.version}}"
- name: Push Docker
run: |
docker push "${{ steps.build.outputs.worker_img}}:${{ steps.build.outputs.worker_version }}"
docker push "${{ steps.build.outputs.worker_test_img}}":"build-${{ matrix.dist }}"
docker push "${{ steps.build.outputs.client_img}}:${{ steps.build.outputs.client_version }}"
build-upload-artifact:
strategy:
fail-fast: false
matrix:
type: [tar.gz, deb, rpm]
name: Build C++ Packages [${{ matrix.type }}]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
ref: ${{ github.ref }}
- name: Build and upload tgz, rpm and deb packages
run: |
cd tools/packaging
./make-${{ matrix.type }}.sh
- name: Publish package as artefact
uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05
with:
if-no-files-found: error
path: tools/packaging/*.${{ matrix.type }}
name: armoniksdk.${{ matrix.type }}