Skip to content

Commit

Permalink
Continuous Deployments CRUD (#415)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcin Maciaszczyk <marcin9yk@icloud.com>
Co-authored-by: Klink <85062+dogmar@users.noreply.github.com>
Co-authored-by: Sebastian Florek <sebastian@plural.sh>
  • Loading branch information
4 people authored Nov 13, 2023
1 parent aff3483 commit 0056c67
Show file tree
Hide file tree
Showing 598 changed files with 49,976 additions and 7,563 deletions.
5 changes: 5 additions & 0 deletions .github/configs/cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Reference: https://github.com/helm/chart-releaser/blob/main/pkg/config/config.go#L40-L65
index-path: "./index.yaml"
release-name-template: "console-chart-v{{ .Version }}"
generate-release-notes: true
skip-existing: true
15 changes: 15 additions & 0 deletions .github/configs/ct-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Reference: https://github.com/helm/chart-testing/blob/master/doc/ct_lint-and-install.md
# Don't add the 'debug' attribute, otherwise the workflow won't work anymore
# Only Used for the CT Install Stage
remote: origin
chart-dirs:
- charts
chart-repos:
- console=https://pluralsh.github.io/console
helm-extra-args: "--timeout 600s"
validate-chart-schema: false
validate-maintainers: true
validate-yaml: true
exclude-deprecated: true
target-branch: main
excluded-charts: []
15 changes: 15 additions & 0 deletions .github/configs/ct-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Reference: https://github.com/helm/chart-testing/blob/master/doc/ct_lint-and-install.md
# Don't add the 'debug' attribute, otherwise the workflow won't work anymore
# Only Used for the CT Lint Stage
remote: origin
chart-dirs:
- charts
chart-repos:
- console=https://pluralsh.github.io/console
helm-extra-args: "--timeout 600s"
validate-chart-schema: false
validate-maintainers: true
validate-yaml: true
exclude-deprecated: true
target-branch: main
excluded-charts: []
42 changes: 42 additions & 0 deletions .github/configs/lintconf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
rules:
braces:
min-spaces-inside: 0
max-spaces-inside: 0
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
brackets:
min-spaces-inside: 0
max-spaces-inside: 0
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
colons:
max-spaces-before: 0
max-spaces-after: 1
commas:
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
comments:
require-starting-space: true
min-spaces-from-content: 1
document-end: disable
document-start: disable # No --- to start a file
empty-lines:
max: 2
max-start: 0
max-end: 0
hyphens:
max-spaces-after: 1
indentation:
spaces: consistent
indent-sequences: whatever # - list indentation will handle both indentation and without
check-multi-line-strings: false
key-duplicates: enable
line-length: disable # Lines can be any length
new-line-at-end-of-file: enable
new-lines:
type: unix
trailing-spaces: enable
truthy:
level: warning
29 changes: 29 additions & 0 deletions .github/workflows/chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish Chart

on:
push:
branches:
- main
- cd-scaffolding
jobs:
publish:
name: Publish helm chart
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Run chart-releaser
id: release
uses: helm/chart-releaser-action@v1.5.0
with:
config: "./.github/configs/cr.yaml"
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18 changes: 9 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
branches: [ '*' ]
jobs:
build:
name: Test Build Docker image
Expand Down Expand Up @@ -65,14 +65,14 @@ jobs:
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-1
key: ${{ runner.os }}-mix-2-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-2
- name: Restore _build
uses: actions/cache@v3
with:
path: _build
key: ${{ runner.os }}-mix-1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-1
key: ${{ runner.os }}-mix-2-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-2
- run: mix deps.get
- run: mix test
- uses: 8398a7/action-slack@v3
Expand All @@ -95,14 +95,14 @@ jobs:
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-1
key: ${{ runner.os }}-mix-2-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-2
- name: Restore _build
uses: actions/cache@v3
with:
path: _build
key: ${{ runner.os }}-mix-1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-1
key: ${{ runner.os }}-mix-2-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-2
- name: get dependencies
run: mix deps.get
- name: update schema
Expand Down
23 changes: 23 additions & 0 deletions .sobelow-skips
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

0AC559834E53BB7C1E4615C7F788020B
0CC883C36985E1DA00B43D00FCCBFD67
191C6C6644B4C9E0C1B328F3CB2661B1
202D30A2850A55B2E9F055FB6D599F38
29335E55D2186ECEBC7879F200C2AA34
2D864C34A280AB48D27E575430F266D7
3B931F08BD9FFCE6ECFAA6906D3E7DAC
450FCB571AFFF0C534CF1F2459A7A406
46804B2AE05109B9911462510EF98088
50BD070EB9424E4C1E27D44D280E7F83
51090F4BB99B03721969C127C838EDB5
556335D2AD1176DF61F08EDDA82ECBDA
58D943EDEC9D14ADA6C8751CE296A299
63E18DEB6A5D77AC95739F3F1ADCD451
74C88F4FCDE7CC470382170D7DB9594A
797BB8E0AA91FAF729F4EC7B96A07377
8144E442A2CB575C66EDCB3E0AEED139
9924E91373FA7104D8ED58C2E597D72C
A7C823E018D7A1BF378A76BB13B1535A
C15BCE8CAF49A8448E904E375BA0C396
CE793866A3BC8A9AD119343CB4247A73
D813FAA43819A0E29039681CE34C2B69
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 23.3.4.19
elixir 1.11.4
erlang 24.3.4.14
elixir 1.12.3
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COPY assets/ ./

RUN yarn run build

FROM bitwalker/alpine-elixir:1.11.4 AS builder
FROM bitwalker/alpine-elixir:1.12.3 AS builder

# The following are build arguments used to change variable parts of the image.
# The name of your application/release (required)
Expand Down Expand Up @@ -90,21 +90,21 @@ RUN apk add --update --no-cache curl ca-certificates unzip wget openssl build-ba
chmod +x /usr/local/bin/terraform

# From this line onwards, we're in a new image, which will be the image used in production
FROM erlang:23.3.4.18-alpine
FROM erlang:24.3.4.6-alpine

ARG CLOUD_SDK_VERSION=273.0.0
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH /google-cloud-sdk/bin:$PATH

COPY --from=tools /usr/local/bin/plural /usr/local/bin/plural
COPY --from=tools /usr/local/bin/helm /usr/local/bin/helm
COPY --from=tools /usr/local/bin/terraform /usr/local/bin/terraform
COPY --from=tools /usr/local/bin/plural /usr/local/bin/plural
COPY --from=tools /usr/local/bin/kubectl /usr/local/bin/kubectl

RUN apk --no-cache add \
ca-certificates \
# python3 \
# py3-pip \
python3 \
py3-pip \
# py-crcmod \
curl \
bash \
Expand All @@ -114,6 +114,10 @@ RUN apk --no-cache add \
git \
gnupg

RUN apk add --no-cache --update --virtual=build gcc musl-dev python3-dev libffi-dev openssl-dev cargo make && \
pip3 install --no-cache-dir --prefer-binary azure-cli && \
apk del build

# The name of your application/release (required)
ARG APP_NAME=console
ARG GIT_COMMIT
Expand All @@ -126,6 +130,10 @@ ENV REPLACE_OS_VARS=true \

WORKDIR /opt/app

RUN addgroup -S --gid 10001 app
RUN adduser -u 10001 -S console -G app
RUN chown console:app /opt/app

RUN mkdir -p /root/.ssh && chmod 0700 /root/.ssh
RUN mkdir -p /root/.plural && mkdir -p /root/.creds && mkdir /root/bin
RUN ln -s /usr/local/bin/plural /usr/local/bin/forge
Expand Down
35 changes: 10 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ PLRL_WWW ?= ../plural/www/src
dep ?= forge-core
GIT_COMMIT ?= abd123
TARGETARCH ?= amd64
ERLANG_VERSION ?= `grep erlang .tool-versions | cut -d' ' -f2`

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}'

find-versions:
gcloud container get-server-config --zone=us-central1-f --format=json > k8s-versions/gke.json
aws eks describe-addon-versions | jq -r ".addons[] | .addonVersions[] | .compatibilities[] | .clusterVersion" | sort | uniq > k8s-versions/eks.json
az aks get-versions --location eastus --output json > k8s-versions/aks.json

build: ## Build the Docker image
docker build --build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg TARGETARCH=$(TARGETARCH) \
Expand All @@ -25,12 +31,13 @@ push: ## push to gcr
docker push gcr.io/$(GCP_PROJECT)/$(APP_NAME):$(APP_VSN)
docker push $(DKR_HOST)/console/$(APP_NAME):$(APP_VSN)

reshim: ## reshims erlang into asdf
cp -r /opt/homebrew/opt/erlang@24/lib/erlang ~/.asdf/installs/erlang/$(ERLANG_VERSION)
asdf reshim erlang $(ERLANG_VERSION)

deploy: ## deploy artifacts to plural
cd plural && plural apply

bump-version: ## bumps the image version of this chart
plural utils image-bump plural/helm/console --tag $(APP_VSN) --path "image.tag"

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

Expand All @@ -40,10 +47,6 @@ testdown: ## tear down test dependencies
migration:
MIX_ENV=test mix ecto.gen.migration $(name)

connectdb: ## proxies the db in kubernetes via kubectl
@echo "run psql -U forge -h 127.0.0.1 forge to connect"
kubectl port-forward statefulset/watchman-postgresql 5432 -n watchman

web: ## starts a local webserver
cd assets && yarn start

Expand All @@ -53,24 +56,6 @@ gql-codegen: ## generates introspection information for our graph
yarn-add: ## adds a yarn dep
cd assets && yarn add $(dep)

import-incidents:
mv assets/src/components/incidents/queries.js queries.js
mv assets/src/components/incidents/Presence.js Presence.js
cp $(PLRL_WWW)/components/incidents/* assets/src/components/incidents
mv queries.js assets/src/components/incidents/queries.js
mv Presence.js assets/src/components/incidents/Presence.js
sed -i '' -- 's/\.\.\/models/graphql/g' assets/src/components/incidents/*
cp $(PLRL_WWW)/components/repos/Tags.js assets/src/components/repos/Tags.js
cp $(PLRL_WWW)/components/utils/AlternatingBox.js assets/src/components/utils/AlternatingBox.js
cp $(PLRL_WWW)/components/utils/TypeaheadEditor.js assets/src/components/utils/TypeaheadEditor.js
cp $(PLRL_WWW)/components/utils/Tooltip.js assets/src/components/utils/Tooltip.js
cp $(PLRL_WWW)/components/utils/SmoothScroller.js assets/src/components/utils/SmoothScroller.js
cp $(PLRL_WWW)/components/utils/hooks.js assets/src/components/utils/hooks.js
cp $(PLRL_WWW)/components/utils/icons.js assets/src/components/utils/icons.js
cp $(PLRL_WWW)/components/utils/TimedCache.js assets/src/components/utils/TimedCache.js
cp $(PLRL_WWW)/utils/date.js assets/src/utils/date.js
cp $(PLRL_WWW)/utils/slate.js assets/src/utils/slate.js

release-vsn: # tags and pushes a new release
@read -p "Version: " tag; \
git checkout master; \
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ brew link --overwrite autoconf@2.69 && \
autoconf -V
```

For Mac Machines, if unable to download Erlang via `asdf` then run:
For Mac Machines, if unable to download Erlang via `asdf` (this is very common, and it might be worthwhile to just get erlang from homebrew) then run:

```sh
brew install erlang@23
cp -r /opt/homebrew/opt/erlang@23/lib/erlang ~/.asdf/installs/erlang/23.3
asdf reshim erlang 23.3
```

You can also use the make target in our root Makefile to automate this, eg:

```sh
make reshim
```
2 changes: 2 additions & 0 deletions assets/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ module.exports = {
rules: {
'@typescript-eslint/consistent-type-exports': 'error',
'import-newlines/enforce': 'off',
// Allow css prop for styled-components
'react/no-unknown-property': ['error', { ignore: ['css'] }],
},
}
1 change: 0 additions & 1 deletion assets/.stylelintrc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
extends:
- '@pluralsh/stylelint-config'
- 'stylelint-config-prettier'
ignoreFiles:
- '**/logo-animation.css'
- '**/message.css'
4 changes: 2 additions & 2 deletions assets/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ generates:
- '/* prettier-ignore */'
config:
scalars:
Map: Map<string, unknown>
Map: Record<string, unknown>
UploadOrUrl: string
DateTime: Date
DateTime: string
Yaml: unknown
hooks:
afterAllFileWrite:
Expand Down
Loading

0 comments on commit 0056c67

Please sign in to comment.