Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
raghu0891 committed Nov 18, 2024
0 parents commit 46e3002
Show file tree
Hide file tree
Showing 137 changed files with 66,026 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: gomod
directory: '/'
schedule:
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: daily
open-pull-requests-limit: 10
118 changes: 118 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Deployments tests (E2E)
on:
pull_request:

concurrency:
group: e2e-tests-plugin-env-${{ github.ref }}
cancel-in-progress: true

env:
INTERNAL_DOCKER_REPO: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com
ENV_JOB_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/plugin-env-tests:ci.${{ github.sha }}
BASE_IMAGE_NAME: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/test-base-image:ci.${{ github.sha }}
PLUGIN_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/plugin
PLUGIN_VERSION: develop
SELECTED_NETWORKS: SIMULATED
PLUGIN_COMMIT_SHA: ${{ github.sha }}
PLUGIN_ENV_USER: ${{ github.actor }}
TEST_LOG_LEVEL: debug

jobs:
build_tests:
runs-on: ubuntu-latest
environment: integration
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Build Base Image
uses: goplugin/pluginv3.0-github-actions/docker/build-push@ce87f8986ca18336cc5015df75916c2ec0a7c4b3 # v2.1.2
with:
tags: ${{ env.BASE_IMAGE_NAME }}
file: Dockerfile.base
AWS_REGION: ${{ secrets.QA_AWS_REGION }}
AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
- name: Base Image Built
run: |
echo "### plugin image used for this test run :link:" >>$GITHUB_STEP_SUMMARY
echo "\`${{ env.PLUGIN_VERSION }}\`" >>$GITHUB_STEP_SUMMARY
echo "### test-base-image image tag for this test run :ship:" >>$GITHUB_STEP_SUMMARY
echo "\`ci.${{ github.sha }}\`" >>$GITHUB_STEP_SUMMARY
- name: Build Test Runner
uses: goplugin/pluginv3.0-github-actions/docker/build-push@ce87f8986ca18336cc5015df75916c2ec0a7c4b3 # v2.1.2
with:
tags: ${{ env.ENV_JOB_IMAGE }}
file: Dockerfile
build-args: |
BASE_IMAGE=${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/test-base-image
IMAGE_VERSION=ci.${{ github.sha }}
AWS_REGION: ${{ secrets.QA_AWS_REGION }}
AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
- name: Test Image Built
run: |
echo "### plugin-env-tests image tag for this test run :ship:" >>$GITHUB_STEP_SUMMARY
echo "\`ci.${{ github.sha }}\`" >>$GITHUB_STEP_SUMMARY
e2e_tests:
runs-on: ubuntu-latest
environment: integration
permissions:
id-token: write
contents: read
env:
TEST_SUITE: local-runner
steps:
- uses: actions/checkout@v3
- name: Run Tests
uses: goplugin/pluginv3.0-github-actions/plugin-testing-framework/run-tests@ce87f8986ca18336cc5015df75916c2ec0a7c4b3 # v2.1.2
with:
cl_repo: ${{ env.PLUGIN_IMAGE }}
cl_image_tag: ${{ env.PLUGIN_VERSION }}
test_command_to_run: unset ENV_JOB_IMAGE && make test_e2e_ci
test_download_vendor_packages_command: go mod download
artifacts_location: ./e2e/logs
publish_check_name: E2E Test Results
token: ${{ secrets.GITHUB_TOKEN }}
go_mod_path: go.mod
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
- name: Upload test log
uses: actions/upload-artifact@v3
if: failure()
with:
name: test-log
path: /tmp/gotest.log

e2e_remote_runner_tests:
runs-on: ubuntu-latest
environment: integration
needs: [build_tests]
permissions:
id-token: write
contents: read
env:
TEST_SUITE: remote-runner
TEST_TRIGGERED_BY: plugin-env-remote-runner-ci
steps:
- uses: actions/checkout@v3
- name: Run Remote Runner Tests
uses: goplugin/pluginv3.0-github-actions/plugin-testing-framework/run-tests@ce87f8986ca18336cc5015df75916c2ec0a7c4b3 # v2.1.2
with:
cl_repo: ${{ env.PLUGIN_IMAGE }}
cl_image_tag: ${{ env.PLUGIN_VERSION }}
test_command_to_run: make test_e2e_ci_remote_runner
test_download_vendor_packages_command: go mod download
artifacts_location: ./e2e/logs
publish_check_name: E2E Remote Runner Test Results
token: ${{ secrets.GITHUB_TOKEN }}
go_mod_path: go.mod
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
- name: Upload test log
uses: actions/upload-artifact@v2
if: failure()
with:
name: remote-runner-test-log
path: /tmp/remoterunnergotest.log
15 changes: 15 additions & 0 deletions .github/workflows/go_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Go test
on:
pull_request:
jobs:
unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
check-latest: true
- name: Test config
run: make test
47 changes: 47 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Linting
on:
pull_request:
jobs:
tools:
name: Get Tool tool-versions
runs-on: ubuntu-latest
steps:
- name: Check out Code
uses: actions/checkout@v3
- uses: goplugin/[email protected]
id: tool-versions
outputs:
golangci-lint-version: ${{ steps.tool-versions.outputs.golangci-lint_version }}
golangci:
name: Linting
runs-on: ubuntu-latest
needs: [tools]
steps:
- name: Check out Code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v${{ needs.tools.outputs.golangci-lint-version }}

vulnerabilities-check:
name: Check for Vulnerabilities
runs-on: ubuntu-latest
needs: [tools]
steps:
- name: Check out Code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
check-latest: true
- name: Write Go List
run: go list -json -deps ./... > go.list
- name: Nancy
uses: sonatype-nexus-community/nancy-github-action@main
24 changes: 24 additions & 0 deletions .github/workflows/publish-test-bash-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish Test Base Image
on:
push:
tags:
- 'v*'

jobs:
publish_test_base_image:
runs-on: ubuntu-latest
environment: integration
permissions:
id-token: write
contents: read
env:
BASE_IMAGE_TAG: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/test-base-image:${{ github.ref_name }}
steps:
- uses: actions/checkout@v3
- name: Build Base Image
uses: goplugin/pluginv3.0-github-actions/docker/build-push@cb4a8f51d77cbf77ea6a765bd1f437ffc7a18730 # v2.0.28
with:
tags: ${{ env.BASE_IMAGE_TAG }}
file: Dockerfile.base
AWS_REGION: ${{ secrets.QA_AWS_REGION }}
AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
23 changes: 23 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Static Analysis
on:
push:
branches: ["master"]
schedule:
- cron: "23 19 * * 4"
jobs:
codeQL:
name: CodeQL Checks
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmd/chaos
bin/
# temp manifest for deployment and validation
tmp-manifest-*.yaml
# remote runner binary
remote.test
e2e.test

.vscode/
.idea/
.direnv/

k3dvolume/
15 changes: 15 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
run:
timeout: 5m
skip-dirs:
- bin
- imports
issues:
exclude-use-default: false
linters-settings:
revive:
rules:
- name: exported
severity: warning
- name: dot-imports
disabled: true
linters:
53 changes: 53 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
project_name: plugin-env

release:
github:
owner: goplugin
name: plugin-env

builds:
- binary: plugin-env
goos:
- darwin
- linux
goarch:
- amd64
- arm64
goarm:
- 6
- 7
gomips:
- hardfloat
env:
- CGO_ENABLED=0
main: cmd/wizard/plugin-env.go
flags:
- -trimpath
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}

archives:
- format: tar.gz
wrap_in_directory: true
name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
files:
- LICENSE
- README.md

snapshot:
name_template: SNAPSHOT-{{ .Commit }}

checksum:
name_template: '{{ .ProjectName }}-{{ .Version }}-checksums.txt'

changelog:
sort: asc
filters:
exclude:
- '(?i)^docs?:'
- '(?i)^docs\([^:]+\):'
- '(?i)^docs\[[^:]+\]:'
- '^tests?:'
- '(?i)^dev:'
- '^build\(deps\): bump .* in /docs \(#\d+\)'
- Merge pull request
- Merge branch
7 changes: 7 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
golang 1.20.1
helm 3.10.3
golangci-lint 1.51.2
kubectl 1.25.5
nodejs 18.13.0
yarn 1.22.19
k3d 5.4.6
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARG BASE_IMAGE
ARG IMAGE_VERSION=latest
FROM ${BASE_IMAGE}:${IMAGE_VERSION}
COPY . testdir/
WORKDIR /go/testdir
RUN ./scripts/buildTests
ENTRYPOINT ["./scripts/entrypoint"]
39 changes: 39 additions & 0 deletions Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# base test for all k8s test runs
FROM golang:1.20-bullseye

ARG BASE_URL
ARG HELM_VERSION
ARG HOME
ARG KUBE_VERSION
ARG NODE_VERSION

ENV GOOS="linux"
ENV BASE_URL="https://get.helm.sh"
ENV HELM_VERSION="3.10.3"
ENV KUBE_VERSION="v1.25.5"
ENV NODE_VERSION=18

RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
apt-get update && apt-get install -y nodejs wget curl git gnupg && \
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
chmod +x ./kubectl && \
mv ./kubectl /usr/local/bin && \
case `uname -m` in \
x86_64) ARCH=amd64; ;; \
armv7l) ARCH=arm; ;; \
aarch64) ARCH=arm64; ;; \
ppc64le) ARCH=ppc64le; ;; \
s390x) ARCH=s390x; ;; \
*) echo "un-supported arch, exit ..."; exit 1; ;; \
esac && \
wget ${BASE_URL}/helm-v${HELM_VERSION}-linux-${ARCH}.tar.gz -O - | tar -xz && \
mv linux-${ARCH}/helm /usr/bin/helm && \
chmod +x /usr/bin/helm && \
rm -rf linux-${ARCH} && \
npm install -g yarn && \
apt-get clean all && \
helm repo add plugin-qa https://raw.githubusercontent.com/goplugin/qa-charts/gh-pages/ && \
helm repo add bitnami https://charts.bitnami.com/bitnami && \
helm repo update

ENTRYPOINT ["sh"]
Loading

0 comments on commit 46e3002

Please sign in to comment.