Skip to content

Commit

Permalink
Fix github actions cockroachdb setup
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Aug 7, 2024
1 parent 7d5a8ea commit f31ebff
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 234 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ jobs:
curl -sL 'https://github.com/pluralsh/plural-cli/releases/download/v0.5.18/plural-cli_0.5.18_Linux_amd64.tar.gz' | tar xzvf -
chmod +x plural
cp plural /usr/local/bin/plural
- run: make install-cockroach
- run: make testup
- name: Restore dependencies cache
uses: actions/cache@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ yarn-error.log*
cert.pem
key.pem


/test-certs/

.vscode
21 changes: 19 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DKR_HOST ?= dkr.plural.sh
dep ?= forge-core
GIT_COMMIT ?= abe123
TARGETARCH ?= amd64
COCKROACH_VSN ?= v24.1.3

help:
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -48,11 +49,27 @@ else
docker push $(DKR_HOST)/plural/${APP_NAME}:$(APP_VSN)
endif

testup: ## sets up dependent services for test
install-cockroach:
sudo curl https://binaries.cockroachdb.com/cockroach-$(COCKROACH_VSN).linux-amd64.tgz | tar -xz && \
sudo cp -i cockroach-$(COCKROACH_VSN).linux-amd64/cockroach /usr/local/bin/ && \
sudo mkdir -p /usr/local/lib/cockroach && \
sudo cp -i cockroach-$(COCKROACH_VSN).linux-amd64/lib/libgeos.so /usr/local/lib/cockroach/ && \
sudo cp -i cockroach-$(COCKROACH_VSN).linux-amd64/lib/libgeos_c.so /usr/local/lib/cockroach/ && \
cockroach version

setup-certs:
mkdir test-certs && \
cockroach cert create-ca --certs-dir test-certs --ca-key test-certs/ca.key && \
cockroach cert create-node localhost 127.0.0.1 --certs-dir test-certs --ca-key test-certs/ca.key && \
cockroach cert create-client root --certs-dir test-certs --ca-key test-certs/ca.key && \
cockroach cert list --certs-dir test-certs

testup: setup-certs ## sets up dependent services for test
docker compose up -d

testdown: ## tear down test dependencies
docker compose down
docker compose down && \
rm -rf test-certs || echo 'no cert folder to remove'

connectdb: ## proxies the db in kubernetes via kubectl
@echo "run psql -U forge -h 127.0.0.1 forge to connect"
Expand Down
8 changes: 7 additions & 1 deletion apps/core/lib/core/services/cloud/configuration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ defmodule Core.Services.Cloud.Configuration do
kas_private
kas_redis
)a)
|> Map.put(:postgres_url, build_pg_url(inst))
|> Map.merge(%{
postgres_url: build_pg_url(inst),
size: "#{size}",
postgres_certificate: certificate(inst)
})
|> Map.put(:size, "#{size}")
|> Enum.map(fn {k, v} -> %{name: Macro.camelize("#{k}"), value: v} end)
end

defp certificate(%ConsoleInstance{cockroach: %CockroachCluster{certificate: cert}}), do: cert

defp build_pg_url(%ConsoleInstance{
configuration: %{dbuser: u, dbpassword: p, database: database},
region: region,
Expand Down
19 changes: 0 additions & 19 deletions test-certs/ca.crt

This file was deleted.

27 changes: 0 additions & 27 deletions test-certs/ca.key

This file was deleted.

19 changes: 0 additions & 19 deletions test-certs/client.plrl.crt

This file was deleted.

27 changes: 0 additions & 27 deletions test-certs/client.plrl.key

This file was deleted.

19 changes: 0 additions & 19 deletions test-certs/client.plural.crt

This file was deleted.

27 changes: 0 additions & 27 deletions test-certs/client.plural.key

This file was deleted.

19 changes: 0 additions & 19 deletions test-certs/client.root.crt

This file was deleted.

27 changes: 0 additions & 27 deletions test-certs/client.root.key

This file was deleted.

20 changes: 0 additions & 20 deletions test-certs/node.crt

This file was deleted.

27 changes: 0 additions & 27 deletions test-certs/node.key

This file was deleted.

0 comments on commit f31ebff

Please sign in to comment.