Skip to content

Commit 35bb4f4

Browse files
authored
ci: use common definition of C++ versions (#103)
This consolidates some of the places we need to specify C++ version numbers into a single `cpp-sdk-versions.env` file. This is a similar approach to Relay Proxy. Updating this file will update: 1. CI unit tests 2. Docker example tests But it won't update the versions found in README or in the Docker files themselves (as they have default values for the new build arg I've introduced.) We need to consider the testing strategy going forward. Should we test a min version, and then also a "current" version? And if so, is that current going to float somehow (like using github's releases API to grab the latest), or be pinned to the latest explicitly (via a workflow, or Renovate or something.)
1 parent 26b1249 commit 35bb4f4

File tree

10 files changed

+58
-14
lines changed

10 files changed

+58
-14
lines changed

.github/actions/ci/action.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ inputs:
55
description: 'Version of Lua to use for building and testing.'
66
required: false
77
default: '5.3'
8-
cpp-sdk-version:
9-
description: 'Version of the C++ Server-side SDK to use for building and testing.'
8+
cpp-sdk-redis-version:
9+
description: 'Version of the C++ Server-side SDK with Redis Source to use for building and testing.'
1010
required: false
11-
default: 'launchdarkly-cpp-server-redis-source-v2.1.3'
1211
rockspec:
1312
description: 'The rockspec file for the server-side SDK.'
1413
required: true
1514

1615
runs:
1716
using: composite
1817
steps:
18+
- name: Get C++ Versions
19+
id: cpp-versions
20+
uses: ./.github/actions/cpp-versions
1921
- name: Install Lua
2022
uses: leafo/gh-actions-lua@35bcb06abec04ec87df82e08caa84d545348536e
2123
with:
@@ -31,7 +33,7 @@ runs:
3133
- name: Install CPP SDK
3234
uses: ./.github/actions/install-cpp-sdk-redis
3335
with:
34-
version: ${{ inputs.cpp-sdk-version }}
36+
version: ${{ inputs.cpp-sdk-redis-version }}
3537
path: cpp-sdk
3638

3739
- name: Build Package
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# The following chunk of yml pulls two C++ sdk version numbers out of a file and
2+
# makes them available to the other actions/workflows in a convenient fashion.
3+
# This allows us to easily bump the version numbers in one place, instead of multiple yml files.
4+
name: C++ Versions
5+
description: Foo
6+
outputs:
7+
sdk:
8+
description: 'The version of the C++ Server-side SDK.'
9+
value: ${{ steps.cpp-versions.outputs.sdk }}
10+
redis_source:
11+
description: 'The version of the C++ Server-side SDK with Redis Source.'
12+
value: ${{ steps.cpp-versions.outputs.redis_source }}
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Set C++ Versions
17+
id: cpp-versions
18+
shell: bash
19+
run: cat ./.github/variables/cpp-sdk-versions.env > $GITHUB_OUTPUT
20+
- name: Display C++ Versions
21+
shell: bash
22+
run: |
23+
echo "${{ format('C++ Server SDK v{0}', steps.cpp-versions.outputs.sdk) }}"
24+
echo "${{ format('C++ Server SDK Redis Source v{0}', steps.cpp-versions.outputs.redis_source) }}"

.github/actions/install-cpp-sdk-redis/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ inputs:
44
version:
55
required: true
66
description: "Version of the C++ SDK with Redis Source."
7-
default: "launchdarkly-cpp-server-redis-source-v2.1.3"
87
path:
98
description: "Where to download the SDK."
109
default: "cpp-sdk"
1110

1211
runs:
1312
using: composite
1413
steps:
14+
- name: Get Default C++ Versions
15+
id: cpp-versions
16+
uses: ./.github/actions/cpp-versions
1517
- name: Download C++ Server-side SDK with Redis Source
1618
uses: robinraju/release-downloader@efa4cd07bd0195e6cc65e9e30c251b49ce4d3e51
1719
id: download-cpp-sdk
1820
with:
1921
repository: "launchdarkly/cpp-sdks"
2022
latest: false
21-
tag: ${{ inputs.version }}
23+
tag: ${{ format('launchdarkly-cpp-server-redis-source-v{0}', inputs.version || steps.cpp-versions.outputs.redis_source) }}
2224
fileName: linux-gcc-x64-dynamic.zip
2325
out-file-path: ${{ inputs.path }}
2426
extract: true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sdk=3.3.3
2+
redis_source=2.1.3

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ jobs:
5252
LD_SDK_KEY: foo
5353
steps:
5454
- uses: actions/checkout@v4
55+
- name: Get C++ Versions
56+
id: cpp-versions
57+
uses: ./.github/actions/cpp-versions
5558
- name: Build ${{ matrix.name }} image
5659
run: |
57-
docker build -t launchdarkly:${{ matrix.name }} -f ./examples/${{ matrix.name }}/Dockerfile .
60+
docker build \
61+
--build-arg="CPP_SDK_VERSION=${{ steps.cpp-versions.outputs.sdk }}" \
62+
-t launchdarkly:${{ matrix.name }} -f ./examples/${{ matrix.name }}/Dockerfile .
5863
- name: Run ${{ matrix.name }} container in background
5964
run: |
6065
docker run -dit --rm --name ${{ matrix.name }} -p 8123:80 --env LD_SDK_KEY="$LD_SDK_KEY" launchdarkly:${{ matrix.name }}
@@ -76,9 +81,14 @@ jobs:
7681
LD_SDK_KEY: foo
7782
steps:
7883
- uses: actions/checkout@v4
84+
- name: Get C++ Versions
85+
id: cpp-versions
86+
uses: ./.github/actions/cpp-versions
7987
- name: Build ${{ matrix.name }} image
8088
run: |
81-
docker build -t launchdarkly:${{ matrix.name }} -f ./examples/${{ matrix.name }}/Dockerfile .
89+
docker build \
90+
--build-arg="CPP_SDK_VERSION=${{ steps.cpp-versions.outputs.sdk }}" \
91+
-t launchdarkly:${{ matrix.name }} -f ./examples/${{ matrix.name }}/Dockerfile .
8292
- name: Run ${{ matrix.name }} container in foreground
8393
run: |
8494
docker run --env LD_SDK_KEY="$LD_SDK_KEY" launchdarkly:${{ matrix.name }} > logs.txt

.github/workflows/cpp-versions.yml

Whitespace-only changes.

.github/workflows/install-lua-sdk.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ on:
2929
description: "Version of the C++ Server-side SDK."
3030
required: false
3131
type: string
32-
default: 'launchdarkly-cpp-server-redis-source-v2.1.3'
3332
workflow_call:
3433
inputs:
3534
package:
@@ -49,7 +48,6 @@ env:
4948
PACKAGE: ${{ inputs.package == null && 'launchdarkly-server-sdk' || inputs.package }}
5049
VERSION: ${{ inputs.version == null && '' || inputs.version }}
5150
LUA_VERSION: ${{ inputs.lua-version == null && '5.3' || inputs.lua-version }}
52-
CPP_SDK_VERSION: ${{ inputs.cpp-sdk-version == null && 'launchdarkly-cpp-server-redis-source-v2.1.3' || inputs.cpp-sdk-version }}
5351
jobs:
5452
install:
5553
runs-on: ubuntu-latest
@@ -74,7 +72,7 @@ jobs:
7472
- name: Install CPP SDK
7573
uses: ./.github/actions/install-cpp-sdk-redis
7674
with:
77-
version: ${{ env.CPP_SDK_VERSION }}
75+
version: ${{ inputs.cpp-sdk-version }}
7876
path: cpp-sdk
7977

8078
- name: Install Package

examples/hello-debian/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FROM debian:bookworm
44
ARG VERSION=2.1.0
55
# {{ x-release-please-end }}
66

7+
ARG CPP_SDK_VERSION=3.3.3
8+
79
# For unknown reasons, it appears that boost.json and boost.url aren't included in the
810
# libboost-all package.
911

@@ -16,7 +18,7 @@ RUN apt-get update && apt-get install -y \
1618

1719

1820
RUN mkdir cpp-sdk-libs
19-
RUN git clone --branch launchdarkly-cpp-server-v3.3.3 https://github.com/launchdarkly/cpp-sdks.git && \
21+
RUN git clone --branch launchdarkly-cpp-server-v${CPP_SDK_VERSION} https://github.com/launchdarkly/cpp-sdks.git && \
2022
cd cpp-sdks && \
2123
mkdir build-dynamic && \
2224
cd build-dynamic && \

examples/hello-haproxy/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FROM ubuntu:22.04
44
ARG VERSION=2.1.0
55
# {{ x-release-please-end }}
66

7+
ARG CPP_SDK_VERSION=3.3.3
8+
79
RUN apt-get update && apt-get install -y \
810
curl luarocks lua5.3 lua5.3-dev \
911
haproxy apt-transport-https ca-certificates \
@@ -13,7 +15,7 @@ RUN add-apt-repository ppa:mhier/libboost-latest && \
1315
apt-get update && \
1416
apt-get install -y boost1.81
1517

16-
RUN curl https://github.com/launchdarkly/cpp-sdks/releases/download/launchdarkly-cpp-server-v3.3.3/linux-gcc-x64-dynamic.zip -L -o /tmp/sdk.zip && \
18+
RUN curl https://github.com/launchdarkly/cpp-sdks/releases/download/launchdarkly-cpp-server-v${CPP_SDK_VERSION}/linux-gcc-x64-dynamic.zip -L -o /tmp/sdk.zip && \
1719
mkdir ./cpp-sdk && \
1820
unzip /tmp/sdk.zip -d ./cpp-sdk && \
1921
rm /tmp/sdk.zip

examples/hello-nginx/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FROM openresty/openresty:jammy
44
ARG VERSION=2.1.0
55
# {{ x-release-please-end }}
66

7+
ARG CPP_SDK_VERSION=3.3.3
8+
79
RUN apt-get update && apt-get install -y \
810
git netbase curl libssl-dev apt-transport-https ca-certificates \
911
software-properties-common \
@@ -15,7 +17,7 @@ RUN add-apt-repository ppa:mhier/libboost-latest && \
1517

1618

1719
RUN mkdir cpp-sdk-libs
18-
RUN git clone --branch launchdarkly-cpp-server-v3.3.3 https://github.com/launchdarkly/cpp-sdks.git && \
20+
RUN git clone --branch launchdarkly-cpp-server-v${CPP_SDK_VERSION} https://github.com/launchdarkly/cpp-sdks.git && \
1921
cd cpp-sdks && \
2022
mkdir build-dynamic && \
2123
cd build-dynamic && \

0 commit comments

Comments
 (0)