Skip to content

Commit df837e1

Browse files
committed
[cueweb] Add tests to ci/cd pipeline
- Adding cueweb tests to the opencue ci/cd pipeline
1 parent 032f701 commit df837e1

File tree

3 files changed

+119
-9
lines changed

3 files changed

+119
-9
lines changed

.github/workflows/testing-pipeline.yml

+97-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: OpenCue Testing Pipeline
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, cueweb ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ master, cueweb ]
88

99
jobs:
1010
test_python_2022:
@@ -104,6 +104,101 @@ jobs:
104104
- name: Run Sphinx build
105105
run: ci/build_sphinx_docs.sh
106106

107+
test_cueweb:
108+
name: Run CueWeb Tests
109+
runs-on: ubuntu-latest
110+
steps:
111+
- name: Checkout repository
112+
uses: actions/checkout@v2
113+
- name: Use Node.js
114+
uses: actions/setup-node@v1
115+
with:
116+
node-version: 21.x
117+
- name: install dependencies for cueweb
118+
run: npm install
119+
working-directory: ./cueweb
120+
- name: Run tests in Docker container
121+
run: npm test
122+
working-directory: ./cueweb
123+
test_rest_gateway:
124+
name: Run Rest Gateway Tests
125+
runs-on: ubuntu-latest
126+
steps:
127+
- name: Checkout repository
128+
uses: actions/checkout@v3
129+
- name: Set up Go
130+
uses: actions/setup-go@v3
131+
with:
132+
go-version: '1.21'
133+
- name: Install Protobuf
134+
run: |
135+
sudo apt-get install -y protobuf-compiler
136+
npm install -g protobuf-compiler
137+
working-directory: ./rest_gateway/opencue_gateway
138+
- name: Install dependencies
139+
run: go mod init opencue_gateway && go mod tidy
140+
working-directory: ./rest_gateway/opencue_gateway
141+
- name: Install Go tools
142+
run: |
143+
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
144+
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
145+
go install github.com/golang-jwt/jwt/v5
146+
go install google.golang.org/protobuf/cmd/protoc-gen-go
147+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
148+
working-directory: ./rest_gateway/opencue_gateway
149+
- name: Copy proto files
150+
run: |
151+
cp -r ./proto /app/proto
152+
- name: Copy gateway files
153+
run: |
154+
cp -r ./rest_gateway/opencue_gateway /app/opencue_gateway
155+
- name: Generate go grpc code
156+
run: |
157+
mkdir -p gen/go && \
158+
protoc -I ../proto/ \
159+
--go_out ./gen/go/ \
160+
--go_opt paths=source_relative \
161+
--go-grpc_out ./gen/go/ \
162+
--go-grpc_opt paths=source_relative \
163+
../proto/*.proto
164+
working-directory: ./rest_gateway/opencue_gateway
165+
- name: Generate grpc-gateway handlers
166+
run: |
167+
protoc -I ../proto/ --grpc-gateway_out ./gen/go \
168+
--grpc-gateway_opt paths=source_relative \
169+
--grpc-gateway_opt generate_unbound_methods=true \
170+
../proto/*.proto
171+
working-directory: ./rest_gateway/opencue_gateway
172+
- name: Run Go Unit Tests
173+
run: go test -v
174+
working-directory: ./rest_gateway/opencue_gateway
175+
# test_rest_gateway:
176+
# name: Run Rest Gateway Tests
177+
# runs-on: ubuntu-latest
178+
# steps:
179+
# - name: Checkout repository
180+
# uses: actions/checkout@v2
181+
# - name: Setup Go
182+
# uses: actions/setup-go@v3
183+
# with:
184+
# go-version: '1.21'
185+
# - name: Initialize go module and install dependencies
186+
# run: |
187+
# cd rest_gateway/opencue_gateway
188+
# go mod init opencue_gateway && go mod tidy
189+
# - name: Install protoc-gen-groc-gateway tool
190+
# run: |
191+
# go install \
192+
# github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest \
193+
# github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest \
194+
# github.com/golang-jwt/jwt/v5@latest \
195+
# google.golang.org/protobuf/cmd/protoc-gen-go@latest \
196+
# google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
197+
# - name: Run rest gateway tests
198+
# run: |
199+
# cd rest_gateway/opencue_gateway
200+
# go test -v ./...
201+
107202
check_changed_files:
108203
name: Check Changed Files
109204
runs-on: ubuntu-latest

rest_gateway/Dockerfile

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
FROM centos7.6-go1.21:latest AS build
1+
# Use the official CentOS 7 image
2+
FROM registry.access.redhat.com/ubi9/ubi:latest AS build
3+
4+
RUN dnf -y update && \
5+
dnf install -y git \
6+
golang \
7+
dnf-plugins-core \
8+
unzip
9+
10+
RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protoc-25.1-linux-x86_64.zip && \
11+
unzip protoc-25.1-linux-x86_64.zip -d /usr/local && \
12+
rm protoc-25.1-linux-x86_64.zip
213

3-
RUN yum install -y \
4-
git \
5-
protobuf3-compiler \
6-
&& yum clean all
714
WORKDIR /app
815
ENV PATH=$PATH:/root/go/bin:/opt/protobuf3/usr/bin/
916

@@ -38,13 +45,18 @@ RUN protoc -I ../proto/ --grpc-gateway_out ./gen/go \
3845
--grpc-gateway_opt generate_unbound_methods=true \
3946
../proto/*.proto
4047

48+
# Environment variables for the rest gateway
49+
ENV CUEBOT_ENDPOINT=tobefilledmanually
50+
ENV REST_PORT=tobefilledmanually
51+
ENV JWT_AUTH_SECRET=tobefilledmanually
52+
4153
# Uncomment this to run go tests
4254
# RUN go test -v
4355

4456
# Build project
4557
RUN go build -o grpc_gateway main.go
4658

47-
FROM centos-7.6.1810:latest
59+
FROM registry.access.redhat.com/ubi9/ubi:latest
4860
COPY --from=build /app/opencue_gateway/grpc_gateway /app/
4961

5062
# Ensure logs folder is created and has correct permissions

rest_gateway/opencue_gateway/main_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ package main
33
import (
44
"net/http"
55
"net/http/httptest"
6+
"os"
67
"testing"
78
"time"
8-
9+
910
"github.com/golang-jwt/jwt/v5"
1011
"github.com/stretchr/testify/assert"
1112
)
1213

1314
func TestJwtMiddleware(t *testing.T) {
15+
os.Setenv("CUEBOT_ENDPOINT", "test_endpoint")
16+
os.Setenv("REST_PORT", "test_port")
1417
jwtSecret := []byte("test_secret")
1518

1619
// Set up a sample handler to use with the middleware

0 commit comments

Comments
 (0)