Skip to content

Commit

Permalink
release: generate deployment files for all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Aug 19, 2024
1 parent b1159fc commit b58995e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,20 @@ jobs:
with:
name: image-replacements.txt
path: ./image-replacements.txt
- name: Create portable coordinator resource definitions
- name: Create coordinator resource definitions
run: |
mkdir -p workspace
nix run .#scripts.write-coordinator-yaml -- "${coordinatorImgTagged}" > workspace/coordinator.yml
nix shell .#contrast --command resourcegen --image-replacements ./image-replacements.txt --platform AKS-CLH-SNP \
--namespace kube-system runtime > workspace/runtime.yml
nix shell .#contrast --command resourcegen --image-replacements ./image-replacements.txt --platform AKS-CLH-SNP \
--add-load-balancers emojivoto-sm-ingress > workspace/emojivoto-demo.yml
for platform in aks-clh-snp k3s-qemu-tdx k3s-qemu-snp rke2-qemu-tdx
do
nix run .#scripts.write-coordinator-yaml -- "${coordinatorImgTagged}" "${platform}" > workspace/coordinator-$platform.yml
nix shell .#contrast --command resourcegen --image-replacements ./image-replacements.txt --platform $platform \
--namespace kube-system runtime > workspace/runtime-$platform.yml
nix shell .#contrast --command resourcegen --image-replacements ./image-replacements.txt --platform $platform \
--add-load-balancers emojivoto-sm-ingress > workspace/emojivoto-demo-$platform.yml
done
- name: Update coordinator policy hash
run: |
yq < workspace/coordinator.yml \
yq < workspace/coordinator-aks-clh-snp.yml \
'select(.kind == "StatefulSet") | .spec.template.metadata.annotations["io.katacontainers.config.agent.policy"]' |
base64 -d | sha256sum | cut -d " " -f1 > cli/cmd/assets/coordinator-policy-hash
Expand All @@ -321,9 +324,9 @@ jobs:
name: contrast-release-artifacts
path: |
result-cli/bin/contrast
workspace/coordinator.yml
workspace/runtime.yml
workspace/emojivoto-demo.yml
workspace/coordinator-*.yml
workspace/runtime-*.yml
workspace/emojivoto-demo-*.yml
- name: Create draft release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
Expand All @@ -334,9 +337,9 @@ jobs:
fail_on_unmatched_files: true
files: |
result-cli/bin/contrast
workspace/coordinator.yml
workspace/runtime.yml
workspace/emojivoto-demo.yml
workspace/coordinator-*.yml
workspace/runtime-*.yml
workspace/emojivoto-demo-*.yml
- name: Reset temporary changes
run: |
git reset --hard ${{ needs.process-inputs.outputs.WORKING_BRANCH }}
Expand Down
7 changes: 4 additions & 3 deletions e2e/release/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestRelease(t *testing.T) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)
defer cancel()

yaml, err := os.ReadFile(path.Join(dir, "runtime.yml"))
yaml, err := os.ReadFile(path.Join(dir, "runtime-aks-clh-snp.yml"))
require.NoError(err)
resources, err := kubeapi.UnmarshalUnstructuredK8SResource(yaml)
require.NoError(err)
Expand All @@ -105,7 +105,7 @@ func TestRelease(t *testing.T) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)
defer cancel()

yaml, err := os.ReadFile(path.Join(dir, "coordinator.yml"))
yaml, err := os.ReadFile(path.Join(dir, "coordinator-aks-clh-snp.yml"))
require.NoError(err)
resources, err := kubeapi.UnmarshalUnstructuredK8SResource(yaml)
require.NoError(err)
Expand All @@ -120,12 +120,13 @@ func TestRelease(t *testing.T) {
require := require.New(t)

require.NoError(os.Mkdir(path.Join(dir, "deployment"), 0o777))
require.NoError(os.Rename(path.Join(dir, "emojivoto-demo.yml"), path.Join(dir, "deployment", "emojivoto-demo.yml")))
require.NoError(os.Rename(path.Join(dir, "emojivoto-demo-aks-clh-snp.yml"), path.Join(dir, "deployment", "emojivoto-demo.yml")))

infos, err := os.ReadDir(path.Join(dir, "deployment"))
require.NoError(err)
for _, info := range infos {
name := path.Join(path.Join(dir, "deployment"), info.Name())
t.Log(name)
yaml, err := os.ReadFile(name)
require.NoError(err)
resources, err := kubeapi.UnmarshalUnstructuredK8SResource(yaml)
Expand Down
3 changes: 2 additions & 1 deletion packages/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,13 @@
];
text = ''
imageRef=$1
platform=$2
tmpdir=$(mktemp -d)
trap 'rm -rf $tmpdir' EXIT
echo "ghcr.io/edgelesssys/contrast/coordinator:latest=$imageRef" > "$tmpdir/image-replacements.txt"
resourcegen --platform AKS-CLH-SNP --image-replacements "$tmpdir/image-replacements.txt" --add-load-balancers coordinator > "$tmpdir/coordinator_base.yml"
resourcegen --platform "$platform" --image-replacements "$tmpdir/image-replacements.txt" --add-load-balancers coordinator > "$tmpdir/coordinator_base.yml"
pushd "$tmpdir" >/dev/null
cp ${pkgs.microsoft.genpolicy.rules-coordinator}/genpolicy-rules.rego rules.rego
Expand Down

0 comments on commit b58995e

Please sign in to comment.