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

[FSSDK-10265] fix: UPS Lookup & Save during batched Decide #375

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b315d5d
ci: fail if triggered from Draft PR
mikechu-optimizely Oct 18, 2024
b5658b1
test: cover new cases
mikechu-optimizely Oct 18, 2024
74d98f7
feat: WIP
mikechu-optimizely Oct 18, 2024
a866266
feat: WIP implementing solution. Tests are
mikechu-optimizely Oct 21, 2024
80bed0a
doc: add comment block
mikechu-optimizely Oct 21, 2024
075e511
chore: remove commented code
mikechu-optimizely Oct 21, 2024
344f451
test: fix via code under test
mikechu-optimizely Oct 21, 2024
c0ce71f
fix: match updates to java PR
mikechu-optimizely Oct 22, 2024
3fab122
fix: code from test results
mikechu-optimizely Oct 22, 2024
bfdc2e0
test: correct test
mikechu-optimizely Oct 22, 2024
a36280a
tests: updated
mikechu-optimizely Oct 22, 2024
c23e898
refactor: rename to match Java ref imp
mikechu-optimizely Oct 22, 2024
03037e2
refactor: extract UserProfileTracker
mikechu-optimizely Oct 22, 2024
2ea917e
test: fixes
mikechu-optimizely Oct 22, 2024
ecda765
fix: tests & code under tests
mikechu-optimizely Oct 22, 2024
e0124c2
ci: also kick off CI if a PR turns to ready for review
mikechu-optimizely Oct 22, 2024
097e90c
ci: try to ready for review trigger
mikechu-optimizely Oct 22, 2024
dbf7eb1
ci: for now just manually kick it off
mikechu-optimizely Oct 22, 2024
5d0584f
ci: remove Fail If Draft Pull Request
mikechu-optimizely Oct 22, 2024
99d59c1
fix: lints & copyright dates
mikechu-optimizely Oct 23, 2024
b439dcb
ci: bump action versions
mikechu-optimizely Oct 23, 2024
5225f7e
chore: csproj auto-edit
mikechu-optimizely Oct 23, 2024
62022c3
fix: super-linter version
mikechu-optimizely Oct 23, 2024
81aae4d
fix: add missing refs to UserProfileTracker.cs
mikechu-optimizely Oct 23, 2024
eced9ed
revert: accidental csproj references
mikechu-optimizely Oct 23, 2024
60bcddf
ci: lots of updates to how we're releasing
mikechu-optimizely Oct 24, 2024
3dc6f0a
fix: lint & dir name
mikechu-optimizely Oct 24, 2024
a6abb60
revert: modifiers on DecisionService & test changes
mikechu-optimizely Nov 5, 2024
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
14 changes: 8 additions & 6 deletions .github/workflows/csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
types: [ opened, synchronize, reopened, ready_for_review ]

jobs:
lintCodebase:
name: Lint Codebase if Not Draft
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
name: Lint Codebase
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files
fetch-depth: 0
- name: Run Super-Linter
uses: github/super-linter@v4
uses: github/super-linter@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
Expand All @@ -37,7 +39,7 @@ jobs:
CURRENT_BRANCH: ${{ github.head_ref || github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1
- name: Setup NuGet
Expand Down Expand Up @@ -65,7 +67,7 @@ jobs:
CURRENT_BRANCH: ${{ github.head_ref || github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
Expand All @@ -88,7 +90,7 @@ jobs:
CURRENT_BRANCH: ${{ github.head_ref || github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
Expand Down
143 changes: 80 additions & 63 deletions .github/workflows/csharp_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ jobs:
name: Set Variables
runs-on: ubuntu-latest
env:
# ⚠️ IMPORTANT: tag should always start with integer & will be used verbatim to string end
TAG: ${{ github.event.release.tag_name }}
steps:
- name: Set semantic version variable
- name: Extract semantic version from tag
id: set_version
run: |
SEMANTIC_VERSION=$(echo "$TAG" | grep -Po "(?<=^|[^0-9])([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?(-[a-zA-Z]+[0-9]*)?)")
# Remove the "v" prefix if it exists and extract the semantic version number
SEMANTIC_VERSION=$(echo "${TAG}" | grep -Po "(?<=^|[^0-9])([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?(-[a-zA-Z]+[0-9]*)?)")
SEMANTIC_VERSION=${SEMANTIC_VERSION#"v"}
if [ -z "${SEMANTIC_VERSION}" ]; then
echo "Tag did not start with a semantic version number (e.g., #.#.#; #.#.#.#; #.#.#.#-beta)"
echo "Error: Tag '${TAG}' does not start with a valid semantic version number (e.g., #.#.#; #.#.#.#; #.#.#.#-beta)"
exit 1
fi
echo "Extracted semantic version: ${SEMANTIC_VERSION}"
echo "semantic_version=${SEMANTIC_VERSION}" >> $GITHUB_OUTPUT
- name: Output tag & semantic version
id: outputs
run: |
echo "$TAG"
echo ${{ steps.set_version.outputs.semantic_version }}
outputs:
tag: $TAG
semanticVersion: ${{ steps.set_version.outputs.semantic_version }}
Expand All @@ -48,9 +45,9 @@ jobs:
- name: Build and strongly name assemblies
run: msbuild /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk /p:Configuration=Release ./OptimizelySDK.NETFramework.sln
- name: Upload Framework artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: nuget-files
name: unsigned-dlls
if-no-files-found: error
path: ./**/bin/Release/**/Optimizely*.dll

Expand All @@ -70,9 +67,9 @@ jobs:
- name: Build and strongly name assemblies
run: dotnet build OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk -c Release
- name: Upload Standard 1.6 artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: nuget-files
name: unsigned-dlls
if-no-files-found: error
path: ./**/bin/Release/**/Optimizely*.dll

Expand All @@ -92,77 +89,95 @@ jobs:
- name: Build and strongly name Standard 2.0 project
run: dotnet build OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk -c Release
- name: Build and strongly name assemblies
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: nuget-files
name: unsigned-dlls
if-no-files-found: error
path: ./**/bin/Release/**/Optimizely*.dll

pack:
name: Sign & pack NuGet package
sign:
name: Send DLLs for signing
needs: [ variables, buildFrameworkVersions, buildStandard16, buildStandard20 ]
runs-on: ubuntu-latest
env:
# TODO: Replace actual values
SIGNING_SERVER_PRIVATE_KEY: ${{ secrets.SIGNING_SERVER_PRIVATE_KEY }}
SIGNING_SERVER_HOST: ${{ secrets.SIGNING_SERVER_HOST }}
SIGNING_SERVER_UPLOAD_PATH: /path/to/UPLOAD/directory
SIGNING_SERVER_DOWNLOAD_PATH: /path/to/DOWNLOAD/directory
steps:
# TODO: Remove this when we're ready to automate
- name: Temporarily halt progress
run: exit 1
- name: Download the unsigned files
uses: actions/download-artifact@v4
with:
name: unsigned-dlls
path: ./unsigned-dlls
- name: Setup SSH
uses: shimataro/ssh-key-action@v2
with:
key: $SIGNING_SERVER_PRIVATE_KEY
- name: Send files to signing server
run: scp -r ./unsigned-dlls $SIGNING_SERVER_HOST:$SIGNING_SERVER_UPLOAD_PATH
- name: Wait for artifact to be published
run: |
for i in {1..60}; do
# Replace with actual path
if ssh $SIGNING_SERVER_HOST "ls $SIGNING_SERVER_DOWNLOAD_PATH"; then
exit 0
fi
sleep 10
done
exit 1
- name: Download signed files
run: |
mkdir ./signed-dlls
scp -r $SIGNING_SERVER_HOST:$SIGNING_SERVER_DOWNLOAD_PATH ./signed-dlls
- name: Delete signed files from server
run: ssh $SIGNING_SERVER_HOST "rm -rf $SIGNING_SERVER_DOWNLOAD_PATH/*"
- name: Upload signed files
uses: actions/upload-artifact@v4
with:
name: signed-dlls
if-no-files-found: error
path: ./signed-dlls

pack:
name: Pack NuGet package
needs: [ variables, sign ]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.variables.outputs.semanticVersion }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ needs.variables.outputs.tag }}
- name: Install mono
run: |
sudo apt update
sudo apt install -y mono-devel
- name: Download NuGet files
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: nuget-files
path: ./nuget-files
name: signed-dlls
path: ./signed-dlls
- name: Organize files
run: |
pushd ./nuget-files
pushd ./signed-dlls
# Move all dlls to the root directory
find . -type f -name "*.dll" -exec mv {} . \;
find . -type f -name "*.dll" -exec mv {} .
popd
# Create directories
mkdir -p nuget/lib/net35/ nuget/lib/net40/ nuget/lib/net45/ nuget/lib/netstandard1.6/ nuget/lib/netstandard2.0/
pushd ./nuget
# Move files to directories
mv ../nuget-files/OptimizelySDK.Net35.dll lib/net35/
mv ../nuget-files/OptimizelySDK.Net40.dll lib/net40/
mv ../nuget-files/OptimizelySDK.dll lib/net45/
mv ../nuget-files/OptimizelySDK.NetStandard16.dll lib/netstandard1.6/
mv ../nuget-files/OptimizelySDK.NetStandard20.dll lib/netstandard2.0/
popd
- name: Setup signing prerequisites
env:
CERTIFICATE_P12: ${{ secrets.CERTIFICATE_P12 }}
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
run: |
pushd ./nuget
echo $CERTIFICATE_P12 | base64 --decode > authenticode.pfx
openssl pkcs12 -in authenticode.pfx -nocerts -nodes -legacy -out key.pem -password env:CERTIFICATE_PASSWORD
openssl rsa -in key.pem -outform PVK -pvk-none -out authenticode.pvk
openssl pkcs12 -in authenticode.pfx -nokeys -nodes -legacy -out cert.pem -password env:CERTIFICATE_PASSWORD
openssl crl2pkcs7 -nocrl -certfile cert.pem -outform DER -out authenticode.spc
popd
- name: Sign the DLLs
run: |
pushd ./nuget
find . -type f -name "*.dll" -print0 | while IFS= read -r -d '' file; do
echo "Signing ${file}"
signcode \
-spc ./authenticode.spc \
-v ./authenticode.pvk \
-a sha1 -$ commercial \
-n "Optimizely, Inc" \
-i "https://www.optimizely.com/" \
-t "http://timestamp.digicert.com" \
-tr 10 \
${file}
rm ${file}.bak
done
rm *.spc *.pem *.pvk *.pfx
mv ../signed-dlls/OptimizelySDK.Net35.dll lib/net35/
mv ../signed-dlls/OptimizelySDK.Net40.dll lib/net40/
mv ../signed-dlls/OptimizelySDK.dll lib/net45/
mv ../signed-dlls/OptimizelySDK.NetStandard16.dll lib/netstandard1.6/
mv ../signed-dlls/OptimizelySDK.NetStandard20.dll lib/netstandard2.0/
popd
- name: Create nuspec
# Uses env.VERSION in OptimizelySDK.nuspec.template
Expand All @@ -175,27 +190,29 @@ jobs:
nuget pack OptimizelySDK.nuspec
popd
- name: Upload nupkg artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: nuget-package
if-no-files-found: error
path: ./nuget/Optimizely.SDK.${{ env.VERSION }}.nupkg

publish:
name: Publish package to NuGet
name: Publish package to NuGet after reviewing the artifact
needs: [ variables, pack ]
runs-on: ubuntu-latest
# Review the `nuget-package` artifact ensuring the dlls are
# organized and signed before approving.
environment: 'i-reviewed-nuget-package-artifact'
env:
VERSION: ${{ needs.variables.outputs.semanticVersion }}
steps:
- name: Download NuGet files
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: nuget-package
path: ./nuget
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
- name: Publish NuGet package
# Unset secrets.NUGET_API_KEY to simulate dry run
run: |
dotnet nuget push ./nuget/Optimizely.SDK.${{ env.VERSION }}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
5 changes: 4 additions & 1 deletion OptimizelySDK.Net35/OptimizelySDK.Net35.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
<Compile Include="..\OptimizelySDK\Bucketing\UserProfile.cs">
<Link>Bucketing\UserProfile.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Bucketing\UserProfileTracker.cs">
<Link>Bucketing\UserProfileTracker.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Utils\ExperimentUtils.cs">
<Link>Bucketing\ExperimentUtils</Link>
</Compile>
Expand Down Expand Up @@ -356,4 +359,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
5 changes: 4 additions & 1 deletion OptimizelySDK.Net40/OptimizelySDK.Net40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
<Compile Include="..\OptimizelySDK\Bucketing\UserProfile.cs">
<Link>Bucketing\UserProfile.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Bucketing\UserProfileTracker.cs">
<Link>Bucketing\UserProfileTracker.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Utils\ExperimentUtils.cs">
<Link>Bucketing\ExperimentUtils</Link>
</Compile>
Expand Down Expand Up @@ -366,4 +369,4 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<Compile Include="..\OptimizelySDK\Bucketing\Decision.cs" />
<Compile Include="..\OptimizelySDK\Bucketing\DecisionService.cs" />
<Compile Include="..\OptimizelySDK\Bucketing\UserProfile.cs" />
<Compile Include="..\OptimizelySDK\Bucketing\UserProfileTracker.cs" />
<Compile Include="..\OptimizelySDK\Bucketing\UserProfileService.cs" />
<Compile Include="..\OptimizelySDK\Bucketing\UserProfileUtil.cs" />
<Compile Include="..\OptimizelySDK\ProjectConfig.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
<Compile Include="..\OptimizelySDK\Bucketing\UserProfile.cs">
<Link>Bucketing\UserProfile.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Bucketing\UserProfileTracker.cs">
<Link>Bucketing\UserProfileTracker.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Bucketing\UserProfileService.cs">
<Link>Bucketing\UserProfileService.cs</Link>
</Compile>
Expand Down
Loading
Loading