Skip to content

Commit da172cc

Browse files
authored
Merge pull request #190 from opentdf/feat/reusable-plat
feat(ci): update x-test to use reusable platform start and kas spin up composite actions
2 parents eee22be + 41ae9ce commit da172cc

File tree

2 files changed

+87
-140
lines changed

2 files changed

+87
-140
lines changed

.github/workflows/xtest.yml

Lines changed: 86 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -57,67 +57,22 @@ jobs:
5757
distribution: "adopt"
5858
server-id: github
5959

60-
######## CHECKOUT THE PLATFORM #############
61-
- name: Check out platform
62-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
63-
with:
64-
repository: opentdf/platform
65-
path: platform
66-
ref: ${{ env.PLATFORM_REF }}
67-
- name: Set up go
68-
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
69-
with:
70-
go-version: "1.22.3"
71-
check-latest: false
72-
cache-dependency-path: |
73-
platform/service/go.sum
74-
platform/examples/go.sum
75-
platform/protocol/go/go.sum
76-
platform/sdk/go.sum
77-
78-
######## SPIN UP BACKEND #############
79-
- run: .github/scripts/init-temp-keys.sh
80-
working-directory: platform
81-
- run: >-
82-
<opentdf-dev.yaml >opentdf.yaml yq e '
83-
(.services.kas.keyring = [{"kid":"ec1","alg":"ec:secp256r1"},{"kid":"r1","alg":"rsa:2048"}])
84-
| (.server.cryptoProvider.standard.keys = [{"kid":"ec1","alg":"ec:secp256r1","private":"kas-ec-private.pem","cert":"kas-ec-cert.pem"},{"kid":"r1","alg":"rsa:2048","private":"kas-private.pem","cert":"kas-cert.pem"}])
85-
'
86-
working-directory: platform
87-
- name: Added Trusted Certs
88-
run: |
89-
sudo chmod -R 777 ./keys
90-
sudo apt-get install -y ca-certificates
91-
sudo cp ./keys/localhost.crt /usr/local/share/ca-certificates
92-
sudo update-ca-certificates
93-
working-directory: platform
94-
- run: docker compose up -d --wait --wait-timeout 240
95-
working-directory: platform
96-
- run: go run ./service provision keycloak
97-
working-directory: platform
98-
- run: go run ./service provision fixtures
99-
working-directory: platform
100-
- uses: JarvusInnovations/background-action@2428e7b970a846423095c79d43f759abf979a635
101-
name: start server in background
60+
######## SPIN UP PLATFORM BACKEND #############
61+
- name: Check out and start up platform with deps/containers
62+
id: run-platform
63+
uses: opentdf/platform/test/start-up-with-containers@main
10264
with:
103-
run: >
104-
go build -o opentdf -v service/main.go
105-
&& .github/scripts/watch.sh opentdf.yaml ./opentdf start
106-
wait-on: |
107-
tcp:localhost:8080
108-
log-output-if: true
109-
wait-for: 90s
110-
working-directory: platform
65+
platform-ref: ${{ env.PLATFORM_REF }}
11166

112-
######## CHECKOUT CLIENT-WEB #############
67+
######## CHECKOUT CLIENT-WEB #############
11368
- name: Check out client-web
11469
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
11570
with:
11671
repository: opentdf/client-web
11772
path: client-web
11873
ref: ${{ env.JS_REF }}
11974

120-
######## SETUP THE JS CLI #############
75+
######## SETUP THE JS CLI #############
12176
- name: build the js cli
12277
run: |
12378
make clean
@@ -135,25 +90,25 @@ jobs:
13590
npm list
13691
working-directory: otdftests/xtest
13792

138-
######## CHECKOUT GO CLI #############
93+
######## CHECKOUT GO CLI #############
13994
- name: Check out otdfctl
14095
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
14196
with:
14297
repository: opentdf/otdfctl
14398
path: otdfctl
14499
ref: ${{ env.OTDFCTL_REF }}
145100

146-
######## SETUP THE GO CLI #############
101+
######## SETUP THE GO CLI #############
147102
- name: Prepare go cli
148103
run: |-
149-
go mod edit -replace github.com/opentdf/platform/protocol/go=../platform/protocol/go
150-
go mod edit -replace github.com/opentdf/platform/sdk=../platform/sdk
104+
go mod edit -replace github.com/opentdf/platform/protocol/go=../${{ steps.run-platform.outputs.platform-working-dir }}/protocol/go
105+
go mod edit -replace github.com/opentdf/platform/sdk=../${{ steps.run-platform.outputs.platform-working-dir }}/sdk
151106
go mod tidy
152107
go build .
153108
cp ./otdfctl ../otdftests/xtest/sdk/go/otdfctl
154109
working-directory: otdfctl
155110

156-
####### CHECKOUT JAVA SDK ##############
111+
####### CHECKOUT JAVA SDK ##############
157112

158113
- name: Check out java-sdk
159114
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
@@ -162,7 +117,7 @@ jobs:
162117
path: java-sdk
163118
ref: ${{ env.JAVA_REF }}
164119

165-
####### SETUP JAVA CLI ##############
120+
####### SETUP JAVA CLI ##############
166121

167122
- name: Build java cli
168123
run: |
@@ -177,7 +132,7 @@ jobs:
177132
cp cmdline/target/cmdline.jar ../otdftests/xtest/sdk/java/cmdline.jar
178133
working-directory: java-sdk
179134

180-
######## RUN THE TESTS #############
135+
######## RUN THE TESTS #############
181136
- name: Install test dependencies
182137
run: |-
183138
pip install -r requirements.txt
@@ -191,91 +146,83 @@ jobs:
191146
run: |-
192147
pytest test_tdfs.py
193148
working-directory: otdftests/xtest
149+
env:
150+
PLATFORM_DIR: '../../${{ steps.run-platform.outputs.platform-working-dir }}'
194151

195-
######## ATTRIBUTE BASED CONFIGURATION #############
196-
- uses: JarvusInnovations/background-action@2428e7b970a846423095c79d43f759abf979a635
197-
name: start another KAS server in background
152+
######## ATTRIBUTE BASED CONFIGURATION #############
153+
- name: Check out and start up platform with deps/containers
154+
uses: opentdf/platform/test/start-additional-kas@main
198155
with:
199-
run: >
200-
<opentdf-dev.yaml >opentdf-beta.yaml yq e '
201-
(.server.port = 8282)
202-
| (.mode = ["kas"])
203-
| (.sdk_config = {"endpoint":"http://localhost:8080","plaintext":true,"client_id":"opentdf","client_secret":"secret"})
204-
'
205-
&& .github/scripts/watch.sh opentdf-beta.yaml ./opentdf --config-file ./opentdf-beta.yaml start
206-
wait-on: |
207-
tcp:localhost:8282
208-
log-output-if: true
209-
wait-for: 90s
210-
working-directory: platform
156+
kas-port: 8282
157+
kas-name: beta
211158

212159
- name: Run attribute based configuration tests
213160
run: |-
214161
pytest test_abac.py
215162
working-directory: otdftests/xtest
216-
163+
env:
164+
PLATFORM_DIR: '../../${{ steps.run-platform.outputs.platform-working-dir }}'
217165
###### TODO: move these unbound tests to v2 platform
218-
# unbound-test-js:
219-
# timeout-minutes: 60
220-
# runs-on: ubuntu-latest
221-
# defaults:
222-
# run:
223-
# working-directory: xtest
224-
# permissions:
225-
# contents: read
226-
# packages: read
227-
# strategy:
228-
# matrix:
229-
# kasversion: [ python-kas, go-kas ]
230-
# steps:
231-
# - uses: actions/checkout@v3
232-
# - name: Set kas-related environment variable
233-
# shell: bash
234-
# run: echo "KAS_VERSION=${{ matrix.kasversion }}" >> $GITHUB_ENV
235-
# - name: Set up Node 18
236-
# uses: actions/setup-node@v3
237-
# with:
238-
# node-version: "18.x"
239-
# registry-url: https://npm.pkg.github.com
240-
# - name: Set up Python 3.10
241-
# uses: actions/setup-python@v4
242-
# with:
243-
# python-version: "3.10"
244-
# # todo: install and activate virtual env for python?
245-
# - name: update packages
246-
# run: |-
247-
# npm ci
248-
# npm install @opentdf/cli@${{ github.event.client_payload.version }} @opentdf/client@${{ github.event.client_payload.version }}
249-
# npm list
250-
# pip3 install -r requirements.txt
251-
# env:
252-
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
253-
# - uses: yokawasa/[email protected]
254-
# with:
255-
# setup-tools: |
256-
# kubectl
257-
# helm
258-
# tilt
259-
# # This should be in sync with the minikube-deployed kube version below
260-
# kubectl: "1.24.1"
261-
# helm: "3.9.2"
262-
# tilt: "0.31.2"
263-
# - run: |
264-
# kubectl version --client
265-
# kustomize version
266-
# tilt version
267-
# - name: start minikube
268-
# id: minikube
269-
# uses: medyagh/setup-minikube@master
270-
# with:
271-
# minikube-version: 1.26.0
272-
# # This should be in sync with the setup-tools version above
273-
# kubernetes-version: 1.24.1
274-
# - name: Run tilt
275-
# run: |-
276-
# [[ -z "${{github.event.inputs.backendVersion}}" ]] && export BACKEND_LATEST_VERSION=$(skopeo list-tags docker://ghcr.io/opentdf/charts/backend \
277-
# | python3 -c "import sys, json; sys.stdout.write([tag for tag in json.load(sys.stdin)['Tags'] if not tag.endswith('.sig')][-1])") || export BACKEND_LATEST_VERSION="${{github.event.inputs.backendVersion}}"
278-
# echo "Testing Backend [$BACKEND_LATEST_VERSION]">>$GITHUB_STEP_SUMMARY
279-
# kubectl version
280-
# tilt ci -f Tiltfile.unbound-js-sdk
281-
166+
# unbound-test-js:
167+
# timeout-minutes: 60
168+
# runs-on: ubuntu-latest
169+
# defaults:
170+
# run:
171+
# working-directory: xtest
172+
# permissions:
173+
# contents: read
174+
# packages: read
175+
# strategy:
176+
# matrix:
177+
# kasversion: [ python-kas, go-kas ]
178+
# steps:
179+
# - uses: actions/checkout@v3
180+
# - name: Set kas-related environment variable
181+
# shell: bash
182+
# run: echo "KAS_VERSION=${{ matrix.kasversion }}" >> $GITHUB_ENV
183+
# - name: Set up Node 18
184+
# uses: actions/setup-node@v3
185+
# with:
186+
# node-version: "18.x"
187+
# registry-url: https://npm.pkg.github.com
188+
# - name: Set up Python 3.10
189+
# uses: actions/setup-python@v4
190+
# with:
191+
# python-version: "3.10"
192+
# # todo: install and activate virtual env for python?
193+
# - name: update packages
194+
# run: |-
195+
# npm ci
196+
# npm install @opentdf/cli@${{ github.event.client_payload.version }} @opentdf/client@${{ github.event.client_payload.version }}
197+
# npm list
198+
# pip3 install -r requirements.txt
199+
# env:
200+
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
201+
# - uses: yokawasa/[email protected]
202+
# with:
203+
# setup-tools: |
204+
# kubectl
205+
# helm
206+
# tilt
207+
# # This should be in sync with the minikube-deployed kube version below
208+
# kubectl: "1.24.1"
209+
# helm: "3.9.2"
210+
# tilt: "0.31.2"
211+
# - run: |
212+
# kubectl version --client
213+
# kustomize version
214+
# tilt version
215+
# - name: start minikube
216+
# id: minikube
217+
# uses: medyagh/setup-minikube@master
218+
# with:
219+
# minikube-version: 1.26.0
220+
# # This should be in sync with the setup-tools version above
221+
# kubernetes-version: 1.24.1
222+
# - name: Run tilt
223+
# run: |-
224+
# [[ -z "${{github.event.inputs.backendVersion}}" ]] && export BACKEND_LATEST_VERSION=$(skopeo list-tags docker://ghcr.io/opentdf/charts/backend \
225+
# | python3 -c "import sys, json; sys.stdout.write([tag for tag in json.load(sys.stdin)['Tags'] if not tag.endswith('.sig')][-1])") || export BACKEND_LATEST_VERSION="${{github.event.inputs.backendVersion}}"
226+
# echo "Testing Backend [$BACKEND_LATEST_VERSION]">>$GITHUB_STEP_SUMMARY
227+
# kubectl version
228+
# tilt ci -f Tiltfile.unbound-js-sdk

xtest/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def temporary_namespace(otdfctl: abac.OpentdfCommandLineTool):
8686
return ns
8787

8888

89-
PLATFORM_DIR = "../../platform"
89+
PLATFORM_DIR = os.getenv("PLATFORM_DIR", "../../platform")
9090

9191

9292
def load_cached_kas_keys() -> abac.PublicKey:

0 commit comments

Comments
 (0)