Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use common definition of C++ versions #103

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ inputs:
description: 'Version of Lua to use for building and testing.'
required: false
default: '5.3'
cpp-sdk-version:
description: 'Version of the C++ Server-side SDK to use for building and testing.'
cpp-sdk-redis-version:
description: 'Version of the C++ Server-side SDK with Redis Source to use for building and testing.'
required: false
default: 'launchdarkly-cpp-server-redis-source-v2.1.3'
rockspec:
description: 'The rockspec file for the server-side SDK.'
required: true

runs:
using: composite
steps:
- name: Get C++ Versions
id: cpp-versions
uses: ./.github/actions/cpp-versions
- name: Install Lua
uses: leafo/gh-actions-lua@35bcb06abec04ec87df82e08caa84d545348536e
with:
Expand All @@ -31,7 +33,7 @@ runs:
- name: Install CPP SDK
uses: ./.github/actions/install-cpp-sdk-redis
with:
version: ${{ inputs.cpp-sdk-version }}
version: ${{ inputs.cpp-sdk-redis-version }}
path: cpp-sdk

- name: Build Package
Expand Down
24 changes: 24 additions & 0 deletions .github/actions/cpp-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The following chunk of yml pulls two C++ sdk version numbers out of a file and
# makes them available to the other actions/workflows in a convenient fashion.
# This allows us to easily bump the version numbers in one place, instead of multiple yml files.
name: C++ Versions
description: Foo
outputs:
sdk:
description: 'The version of the C++ Server-side SDK.'
value: ${{ steps.cpp-versions.outputs.sdk }}
redis_source:
description: 'The version of the C++ Server-side SDK with Redis Source.'
value: ${{ steps.cpp-versions.outputs.redis_source }}
runs:
using: composite
steps:
- name: Set C++ Versions
id: cpp-versions
shell: bash
run: cat ./.github/variables/cpp-sdk-versions.env > $GITHUB_OUTPUT
- name: Display C++ Versions
shell: bash
run: |
echo "${{ format('C++ Server SDK v{0}', steps.cpp-versions.outputs.sdk) }}"
echo "${{ format('C++ Server SDK Redis Source v{0}', steps.cpp-versions.outputs.redis_source) }}"
6 changes: 4 additions & 2 deletions .github/actions/install-cpp-sdk-redis/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ inputs:
version:
required: true
description: "Version of the C++ SDK with Redis Source."
default: "launchdarkly-cpp-server-redis-source-v2.1.3"
path:
description: "Where to download the SDK."
default: "cpp-sdk"

runs:
using: composite
steps:
- name: Get Default C++ Versions
id: cpp-versions
uses: ./.github/actions/cpp-versions
- name: Download C++ Server-side SDK with Redis Source
uses: robinraju/release-downloader@efa4cd07bd0195e6cc65e9e30c251b49ce4d3e51
id: download-cpp-sdk
with:
repository: "launchdarkly/cpp-sdks"
latest: false
tag: ${{ inputs.version }}
tag: ${{ format('launchdarkly-cpp-server-redis-source-v{0}', inputs.version || steps.cpp-versions.outputs.redis_source) }}
fileName: linux-gcc-x64-dynamic.zip
out-file-path: ${{ inputs.path }}
extract: true
2 changes: 2 additions & 0 deletions .github/variables/cpp-sdk-versions.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sdk=3.3.3
redis_source=2.1.3
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ jobs:
LD_SDK_KEY: foo
steps:
- uses: actions/checkout@v4
- name: Get C++ Versions
id: cpp-versions
uses: ./.github/actions/cpp-versions
- name: Build ${{ matrix.name }} image
run: |
docker build -t launchdarkly:${{ matrix.name }} -f ./examples/${{ matrix.name }}/Dockerfile .
docker build \
--build-arg="CPP_SDK_VERSION=${{ steps.cpp-versions.outputs.sdk }}" \
-t launchdarkly:${{ matrix.name }} -f ./examples/${{ matrix.name }}/Dockerfile .
- name: Run ${{ matrix.name }} container in background
run: |
docker run -dit --rm --name ${{ matrix.name }} -p 8123:80 --env LD_SDK_KEY="$LD_SDK_KEY" launchdarkly:${{ matrix.name }}
Expand All @@ -76,9 +81,14 @@ jobs:
LD_SDK_KEY: foo
steps:
- uses: actions/checkout@v4
- name: Get C++ Versions
id: cpp-versions
uses: ./.github/actions/cpp-versions
- name: Build ${{ matrix.name }} image
run: |
docker build -t launchdarkly:${{ matrix.name }} -f ./examples/${{ matrix.name }}/Dockerfile .
docker build \
--build-arg="CPP_SDK_VERSION=${{ steps.cpp-versions.outputs.sdk }}" \
-t launchdarkly:${{ matrix.name }} -f ./examples/${{ matrix.name }}/Dockerfile .
- name: Run ${{ matrix.name }} container in foreground
run: |
docker run --env LD_SDK_KEY="$LD_SDK_KEY" launchdarkly:${{ matrix.name }} > logs.txt
Expand Down
Empty file.
4 changes: 1 addition & 3 deletions .github/workflows/install-lua-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ on:
description: "Version of the C++ Server-side SDK."
required: false
type: string
default: 'launchdarkly-cpp-server-redis-source-v2.1.3'
workflow_call:
inputs:
package:
Expand All @@ -49,7 +48,6 @@ env:
PACKAGE: ${{ inputs.package == null && 'launchdarkly-server-sdk' || inputs.package }}
VERSION: ${{ inputs.version == null && '' || inputs.version }}
LUA_VERSION: ${{ inputs.lua-version == null && '5.3' || inputs.lua-version }}
CPP_SDK_VERSION: ${{ inputs.cpp-sdk-version == null && 'launchdarkly-cpp-server-redis-source-v2.1.3' || inputs.cpp-sdk-version }}
jobs:
install:
runs-on: ubuntu-latest
Expand All @@ -74,7 +72,7 @@ jobs:
- name: Install CPP SDK
uses: ./.github/actions/install-cpp-sdk-redis
with:
version: ${{ env.CPP_SDK_VERSION }}
version: ${{ inputs.cpp-sdk-version }}
path: cpp-sdk

- name: Install Package
Expand Down
4 changes: 3 additions & 1 deletion examples/hello-debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ FROM debian:bookworm
ARG VERSION=2.1.0
# {{ x-release-please-end }}

ARG CPP_SDK_VERSION=3.3.3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these dockerfiles, the CPP_SDK_VERSION arg is injected by CI. But since it's also hardcoded in the file (so that people can run these examples locally), we'd still have to remember to update these manually.

See PR body for a solution.

# For unknown reasons, it appears that boost.json and boost.url aren't included in the
# libboost-all package.

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


RUN mkdir cpp-sdk-libs
RUN git clone --branch launchdarkly-cpp-server-v3.3.3 https://github.com/launchdarkly/cpp-sdks.git && \
RUN git clone --branch launchdarkly-cpp-server-v${CPP_SDK_VERSION} https://github.com/launchdarkly/cpp-sdks.git && \
cd cpp-sdks && \
mkdir build-dynamic && \
cd build-dynamic && \
Expand Down
4 changes: 3 additions & 1 deletion examples/hello-haproxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ FROM ubuntu:22.04
ARG VERSION=2.1.0
# {{ x-release-please-end }}

ARG CPP_SDK_VERSION=3.3.3

RUN apt-get update && apt-get install -y \
curl luarocks lua5.3 lua5.3-dev \
haproxy apt-transport-https ca-certificates \
Expand All @@ -13,7 +15,7 @@ RUN add-apt-repository ppa:mhier/libboost-latest && \
apt-get update && \
apt-get install -y boost1.81

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 && \
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 && \
mkdir ./cpp-sdk && \
unzip /tmp/sdk.zip -d ./cpp-sdk && \
rm /tmp/sdk.zip
Expand Down
4 changes: 3 additions & 1 deletion examples/hello-nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ FROM openresty/openresty:jammy
ARG VERSION=2.1.0
# {{ x-release-please-end }}

ARG CPP_SDK_VERSION=3.3.3

RUN apt-get update && apt-get install -y \
git netbase curl libssl-dev apt-transport-https ca-certificates \
software-properties-common \
Expand All @@ -15,7 +17,7 @@ RUN add-apt-repository ppa:mhier/libboost-latest && \


RUN mkdir cpp-sdk-libs
RUN git clone --branch launchdarkly-cpp-server-v3.3.3 https://github.com/launchdarkly/cpp-sdks.git && \
RUN git clone --branch launchdarkly-cpp-server-v${CPP_SDK_VERSION} https://github.com/launchdarkly/cpp-sdks.git && \
cd cpp-sdks && \
mkdir build-dynamic && \
cd build-dynamic && \
Expand Down
Loading