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

attempt to run k8s in gha #873

Merged
merged 43 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a67e9ce
Make `local.env` creation idempotent in `task setup`
myieye Jun 13, 2024
4cd0ee2
initial workflow attempt
hahn-kev Jun 10, 2024
fe26583
add pr trigger
hahn-kev Jun 10, 2024
c11d3f5
fix help kind version
hahn-kev Jun 10, 2024
e267c0f
only run codeql when code changes
hahn-kev Jun 10, 2024
93f0d9a
use local-dev instead of develop since cert-manager is missing
hahn-kev Jun 10, 2024
8fccda1
breakout local.env setup and call in k8s workflow to fix issue where …
hahn-kev Jun 10, 2024
bb5797d
create languagedepot namespace before applying
hahn-kev Jun 10, 2024
a189893
correct waiit action to wait for pods and select by label, specify na…
hahn-kev Jun 10, 2024
86a9dbe
add missing namespace
hahn-kev Jun 10, 2024
d2bbb69
use skaffold to setup cluster, run dotnet test with GHA logger
hahn-kev Jun 10, 2024
db4001e
setup better failure logs, remove skaffold since we don't want to bui…
hahn-kev Jun 10, 2024
7e1ace2
switch from kind to mini kube because of PVC issues
hahn-kev Jun 10, 2024
6fff47c
introduce a kustomize layer for gha, change storage class used
hahn-kev Jun 10, 2024
6467ead
correct name of kustomize file, change back to kind
hahn-kev Jun 10, 2024
44e278f
pull image with docker before pulling with kind
hahn-kev Jun 10, 2024
fed1f60
donn't attempt to load images via kind
hahn-kev Jun 10, 2024
80be6b1
change local-dev-init back to use busybox, increase timeout when wait…
hahn-kev Jun 10, 2024
a495240
prevent doubl prefixing busybox with the tag
hahn-kev Jun 10, 2024
f300cfd
increase log tail length to see error
hahn-kev Jun 10, 2024
1a1118b
add frontend folder to gha for dotnet to write the schema to.
hahn-kev Jun 10, 2024
65a5673
ensure that kind forwards localhost:80 to ingress in gha
hahn-kev Jun 10, 2024
a373210
ensure we wait for ingress to be ready
hahn-kev Jun 10, 2024
7dc0444
wait for app.kubernetes.io/component=controller
hahn-kev Jun 10, 2024
258d916
use port forwarding to access ingress
hahn-kev Jun 10, 2024
b1db609
explicitly build and restore to ensure that MercurialExtensions is found
hahn-kev Jun 10, 2024
f8dade4
disable export to honeycomb in gha
hahn-kev Jun 10, 2024
f995fd8
rename workflow
hahn-kev Jun 10, 2024
653d8ed
add blame timeout to integration tests running on gha.
hahn-kev Jun 10, 2024
38341cb
Merge branch 'develop' into chore/run-k8s-in-gha
hahn-kev Aug 2, 2024
f793654
install cert-manager during deployment
hahn-kev Aug 6, 2024
c1d39c1
ensure cert manager is ready before deploying
hahn-kev Aug 6, 2024
d650909
don't try to build maui stuff
hahn-kev Aug 6, 2024
6396b77
configure gha k8s deployment to run as the staging environment.
hahn-kev Aug 6, 2024
2f828dc
switch back to Development, and make /var/www writable
hahn-kev Aug 6, 2024
0e1af3d
fix test error when ServerHostname includes a port
hahn-kev Aug 7, 2024
a1e423a
increase timeout waiting for pods to be ready
hahn-kev Aug 7, 2024
9c896a2
update Chorus version to fix issue with resumable not respecting port…
hahn-kev Aug 14, 2024
cb08ad2
include flakey tests in self contained integration tests
hahn-kev Aug 14, 2024
949374b
setup integration tests to run after pr builds or push to develop.
hahn-kev Aug 15, 2024
29e682a
fix syntax of variable replacement
hahn-kev Aug 15, 2024
e97560f
Merge branch 'develop' into chore/run-k8s-in-gha
hahn-kev Aug 15, 2024
3306112
disable self hosted integration tests since they're flakey
hahn-kev Aug 16, 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
5 changes: 5 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
branches: [ "develop", "main" ]
pull_request:
branches: [ "develop", "main" ]
paths:
- "**/*.cs"
- "**/*.csproj"
- "**/*.ts"
- "**/*.js"
schedule:
- cron: '34 21 * * 2'

Expand Down
31 changes: 20 additions & 11 deletions .github/workflows/develop-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,24 @@ jobs:
k8s-environment: develop
deploy-domain: lexbox.dev.languagetechnology.org

integration-tests:
name: Integration tests
concurrency: develop
uses: ./.github/workflows/integration-test.yaml
permissions:
checks: write
secrets: inherit
needs: deploy-api
integration-test-gha:
name: Self hosted integration tests
needs: [build-api, set-version]
uses: ./.github/workflows/integration-test-gha.yaml
with:
environment: develop
runs-on: self-hosted
hg-version: 6
lexbox-api-tag: ${{ needs.set-version.outputs.version }}


# for now disabling integration tests on self hosted since they're flaky, depend on tests in gha above
# integration-tests:
# name: Integration tests
# concurrency: develop
# uses: ./.github/workflows/integration-test.yaml
# permissions:
# checks: write
# secrets: inherit
# needs: deploy-api
# with:
# environment: develop
# runs-on: self-hosted
# hg-version: 6
70 changes: 70 additions & 0 deletions .github/workflows/integration-test-gha.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Self contained integration tests
on:
workflow_dispatch:
inputs:
lexbox-api-tag:
description: 'The version of lexbox-api to test'
default: 'develop'
required: true
workflow_call:
inputs:
lexbox-api-tag:
description: 'The version of lexbox-api to test'
default: 'develop'
type: string
required: true

jobs:
execute:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Task
uses: arduino/setup-task@v2
- run: task setup-local-env
- name: setup k8s
uses: helm/[email protected]
with:
config: deployment/gha/kind.yaml
- name: Verify k8s
run: |
kubectl cluster-info
kubectl get nodes
- name: Update image lexbox-api version
uses: mikefarah/yq@0b34c9a00de1c575a34eea05af1d956a525c4fc1 # v4.34.2
with:
cmd: yq eval -i '(.images.[] | select(.name == "ghcr.io/sillsdev/lexbox-api").newTag) = "${{ inputs.lexbox-api-tag }}"' "./deployment/gha/kustomization.yaml"
- name: deploy
run: |
kubectl create namespace languagedepot
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.0/cert-manager.yaml
kubectl wait --for=condition=Ready --timeout=90s pod -l 'app in (cert-manager, webhook)' -n cert-manager
kubectl apply -k ./deployment/gha
kubectl wait --for=condition=Ready --timeout=120s pod -l 'app.kubernetes.io/component=controller' -n languagedepot
kubectl wait --for=condition=Ready --timeout=120s pod -l 'app in (lexbox, ui, hg, db)' -n languagedepot
- name: status
if: failure()
run: |
kubectl describe pods -l 'app in (lexbox, ui, hg, db)' -n languagedepot
echo "========== LOGS =========="
kubectl logs -l 'app in (lexbox, ui, hg, db)' -n languagedepot --prefix --all-containers --tail=50
echo "========== INGRESS =========="
kubectl logs -l 'app.kubernetes.io/name=ingress-nginx' -n languagedepot --prefix --all-containers --tail=50
- name: forward ingress
run: kubectl port-forward service/ingress-nginx-controller 6579:80 -n languagedepot &
- name: verify ingress
run: curl -v http://localhost:6579
- name: build
run: dotnet restore LexBoxOnly.slnf && dotnet build --no-restore LexBoxOnly.slnf
- name: Dotnet test
env:
TEST_SERVER_HOSTNAME: 'localhost:6579'
TEST_STANDARD_HG_HOSTNAME: 'hg.localhost:6579'
TEST_RESUMABLE_HG_HOSTNAME: 'resumable.localhost:6579'
TEST_PROJECT_CODE: 'sena-3'
TEST_DEFAULT_PASSWORD: 'pass'
run: dotnet test LexBoxOnly.slnf --logger GitHubActions --filter "Category=Integration|Category=FlakyIntegration" --blame-hang-timeout 40m

8 changes: 7 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ includes:

tasks:
setup:
deps: [ setup-win, setup-unix ]
deps: [ setup-win, setup-unix, setup-local-env ]
cmds:
- git config blame.ignoreRevsFile .git-blame-ignore-revs
- kubectl --context=docker-desktop apply -f deployment/setup/namespace.yaml
Expand All @@ -51,6 +51,12 @@ tasks:
- wget -c -O {{.DATA_DIR}}/sena-3.zip 'https://drive.google.com/uc?export=download&id=1I-hwc0RHoQqW774gbS5qR-GHa1E7BlsS'
- wget -c -O {{.DATA_DIR}}/empty.zip 'https://drive.google.com/uc?export=download&id=1p73u-AGdSwNkg_5KEv9-4iLRuN-1V-LD'
- wget -c -O {{.DATA_DIR}}/elawa.zip 'https://drive.usercontent.google.com/download?export=download&id=1Jk-eSDho8ATBMS-Kmfatwi-MWQth26ro&confirm=t'
setup-local-env:
cmds:
- echo "HONEYCOMB_API_KEY=__REPLACE__" > deployment/local-dev/local.env
- echo "#OTEL_SDK_DISABLED=true" >> deployment/local-dev/local.env
- echo "GOOGLE_OAUTH_CLIENT_ID=__REPLACE__.apps.googleusercontent.com" >> deployment/local-dev/local.env
- echo "GOOGLE_OAUTH_CLIENT_SECRET=__REPLACE__" >> deployment/local-dev/local.env

# k8s
up:
Expand Down
14 changes: 4 additions & 10 deletions backend/Testing/SyncReverseProxy/SendReceiveServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,8 @@ public async Task SendReceiveAfterProjectReset(HgProtocol protocol)
var srResult = _sendReceiveService.SendReceiveProject(sendReceiveParams, AdminAuth);

// First, save the current value of `hg tip` from the original project
var tipUri = new UriBuilder
{
Scheme = TestingEnvironmentVariables.HttpScheme,
Host = TestingEnvironmentVariables.ServerHostname,
Path = $"hg/{projectConfig.Code}/tags",
Query = "?style=json"
};
var response = await _adminApiTester.HttpClient.GetAsync(tipUri.Uri);
var tipUri = $"/hg/{projectConfig.Code}/tags?style=json";
var response = await _adminApiTester.HttpClient.GetAsync(tipUri);
var jsonResult = await response.Content.ReadFromJsonAsync<JsonObject>();
var originalTip = jsonResult?["node"]?.AsValue()?.ToString();
originalTip.ShouldNotBeNull();
Expand All @@ -155,7 +149,7 @@ public async Task SendReceiveAfterProjectReset(HgProtocol protocol)
await _adminApiTester.HttpClient.PostAsync($"{_adminApiTester.BaseUrl}/api/project/finishResetProject/{projectConfig.Code}", null);

// Step 2: verify project is now empty, i.e. tip is "0000000..."
response = await _adminApiTester.HttpClient.GetAsync(tipUri.Uri);
response = await _adminApiTester.HttpClient.GetAsync(tipUri);
jsonResult = await response.Content.ReadFromJsonAsync<JsonObject>();
var emptyTip = jsonResult?["node"]?.AsValue()?.ToString();
emptyTip.ShouldNotBeNull();
Expand All @@ -178,7 +172,7 @@ public async Task SendReceiveAfterProjectReset(HgProtocol protocol)
_output.WriteLine(srResultStep3);

// Step 4: verify project tip is same hash as original project tip
response = await _adminApiTester.HttpClient.GetAsync(tipUri.Uri);
response = await _adminApiTester.HttpClient.GetAsync(tipUri);
jsonResult = await response.Content.ReadFromJsonAsync<JsonObject>();
var postSRTip = jsonResult?["node"]?.AsValue()?.ToString();
postSRTip.ShouldNotBeNull();
Expand Down
6 changes: 5 additions & 1 deletion backend/Testing/Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Choose>
<When Condition=" '$(MercurialVersion)' == '6' ">
<ItemGroup>
<PackageReference Include="SIL.Chorus.LibChorus" Version="6.0.0-beta0048" />
<PackageReference Include="SIL.Chorus.LibChorus" Version="6.0.0-beta0049" />
<PackageReference Include="SIL.Chorus.Mercurial" Version="6.*" />
</ItemGroup>
</When>
Expand Down Expand Up @@ -48,6 +48,10 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="XunitXml.TestLogger" Version="3.1.17" />
</ItemGroup>

Expand Down
6 changes: 6 additions & 0 deletions deployment/gha/app-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
environment-name: "Development"
7 changes: 7 additions & 0 deletions deployment/gha/change-storage-class.patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hg-repos
namespace: languagedepot
spec:
storageClassName: standard # Because kind only supports the standard storage class
2 changes: 2 additions & 0 deletions deployment/gha/kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
24 changes: 24 additions & 0 deletions deployment/gha/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: languagedepot

resources:
- ../local-dev/

patches:
- path: lexbox.patch.yaml
- target:
version: v1
kind: PersistentVolumeClaim
path: change-storage-class.patch.yaml
- path: app-config.yaml

images:
- name: local-dev-init #revert change made by local-dev patch
newName: busybox
- name: ghcr.io/sillsdev/lexbox-api
newTag: develop #will be replaced by workflow
- name: ghcr.io/sillsdev/lexbox-ui
newTag: develop
- name: ghcr.io/sillsdev/lexbox-hgweb
newTag: latest
37 changes: 37 additions & 0 deletions deployment/gha/lexbox.patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: lexbox
namespace: languagedepot
spec:
template:
spec:
containers:
- name: lexbox-api
volumeMounts:
- mountPath: /frontend
name: gql-schema
- mountPath: /var/www
name: www
- name: otel-collector
env: #don't try to export to honeycomb
- name: COLLECTOR_CONFIG_OVERRIDE
value: |
exporters:
otlp/aspire:
endpoint: localhost:18889
tls:
insecure: true
service:
pipelines:
traces:
exporters: [otlp/aspire]
metrics:
exporters: [otlp/aspire]
logs:
exporters: [otlp/aspire]
volumes:
- name: gql-schema
emptyDir: {}
- name: www
emptyDir: {}
Loading