From 9540a95e0590549ed2c6b1c46ef26d028a525b37 Mon Sep 17 00:00:00 2001 From: gatici Date: Mon, 5 Feb 2024 14:18:51 +0300 Subject: [PATCH] Add Github workflows Signed-off-by: gatici --- .github/ISSUE_TEMPLATE/bug_report.md | 39 +++++++++++ .github/pull_request_template.md | 13 ++++ .github/workflows/issues.yaml | 11 ++++ .github/workflows/lint-pr.yaml | 20 ++++++ .github/workflows/main.yaml | 30 +++++++++ LICENSE | 2 +- README.md | 56 +--------------- modules/sdcore-control-plane-k8s/README.md | 65 +++++++++++++++++++ .../sdcore-control-plane-k8s/main.tf | 0 .../sdcore-control-plane-k8s/terraform.tf | 2 +- .../sdcore-control-plane-k8s/variables.tf | 0 terraform.tfvars | 17 ----- 12 files changed, 182 insertions(+), 73 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/issues.yaml create mode 100644 .github/workflows/lint-pr.yaml create mode 100644 .github/workflows/main.yaml create mode 100644 modules/sdcore-control-plane-k8s/README.md rename main.tf => modules/sdcore-control-plane-k8s/main.tf (100%) rename terraform.tf => modules/sdcore-control-plane-k8s/terraform.tf (83%) rename variables.tf => modules/sdcore-control-plane-k8s/variables.tf (100%) delete mode 100644 terraform.tfvars diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..1d9e946 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,39 @@ +--- +name: Bug report +about: Create a bug report to help us improve +title: "" +labels: ["bug"] +assignees: '' +--- + +#### Describe the bug + + +#### To Reproduce + + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +#### Expected behavior + + +#### Screenshots + + +#### Logs + + +#### Environment + +- Charm / library version (if relevant): +- Juju version (output from `juju --version`): +- Cloud Environment: +- Kubernetes version (output from `kubectl version --short`): +- Terraform version (output from `terraform version`): + +#### Additional context + + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..ed67d9f --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +# Description + +Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. + +# Checklist: + +- [ ] My code follows the [style guidelines](/CONTRIBUTING.md) of this project +- [ ] I have performed a self-review of my own code +- [ ] I have made corresponding changes to the documentation +- [ ] I have added tests that validate the behaviour of the software +- [ ] I validated that new and existing unit tests pass locally with my changes +- [ ] Any dependent changes have been merged and published in downstream modules +- [ ] I have bumped the version of the library \ No newline at end of file diff --git a/.github/workflows/issues.yaml b/.github/workflows/issues.yaml new file mode 100644 index 0000000..ee3d9dd --- /dev/null +++ b/.github/workflows/issues.yaml @@ -0,0 +1,11 @@ +name: Sync Issues to JIRA + +on: + issues: + types: [opened, reopened, closed] + +jobs: + update: + name: Update Issue + uses: canonical/sdcore-github-workflows/.github/workflows/issues.yaml@main + secrets: inherit diff --git a/.github/workflows/lint-pr.yaml b/.github/workflows/lint-pr.yaml new file mode 100644 index 0000000..d54e174 --- /dev/null +++ b/.github/workflows/lint-pr.yaml @@ -0,0 +1,20 @@ +name: "Lint PR" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..8b756ea --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,30 @@ + name: Pull Request + + on: + pull_request: + paths: + - '**.tf' + + jobs: + build: + name: Terraform Checks and Plans + runs-on: ubuntu-latest + steps: + - name: Checkout the repository to the runner + uses: actions/checkout@v3 + + - name: HashiCorp - Setup Terraform + uses: hashicorp/setup-terraform@v3 + + - name: Terraform Format + id: fmt + run: terraform fmt -recursive -check + continue-on-error: true + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color \ No newline at end of file diff --git a/LICENSE b/LICENSE index 8d771e1..c4a371b 100644 --- a/LICENSE +++ b/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2023 Canonical Ltd. + Copyright 2024 Canonical Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index fb0fea3..d1abaee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# SD-Core Control Plane Terraform Module +# SD-Core Terraform Module -This SD-Core Control Plane Terraform module aims to deploy the [sdcore-control-plane-k8s bundle](https://charmhub.io/sdcore-control-plane-k8s) via Terraform. +This SD-Core Terraform module aims to deploy the [sdcore-k8s bundle](https://charmhub.io/sdcore-k8s) via Terraform. ## Getting Started @@ -11,55 +11,3 @@ The following software and tools needs to be installed and should be running in - `microk8s` - `juju 3.x` - `terrafom` - -### Deploy the sdcore-control-plane-k8s bundle using Terraform - -Make sure that `storage`, `multus` and `metallb` plugins are enabled for Microk8s: - -```console -sudo microk8s enable hostpath-storage multus -sudo microk8s enable metallb:10.0.0.2-10.0.0.4 -``` - -Initialise the provider: - -```console -terraform init -``` - -Customize the configuration inputs under `terraform.tfvars` file according to requirement. - -Replace the values in the `terraform.tfvars` file. The provided model-name is not expected to pre-exist and will be created by Juju Terraform Provider. - -```yaml -# Mandatory Config Options -model_name = "put your model-name here" -``` - -Run Terraform Plan by providing var-file: - -```console -terraform plan -var-file="terraform.tfvars" -``` - -Deploy the resources, skip the approval: - -```console -terraform apply -auto-approve -``` - -### Check the Output - -Run `juju switch ` to switch to the target Juju model and observe the status of the applications. - -```console -juju status --relations -``` - -### Clean up - -Remove the applications: - -```console -terraform destroy -auto-approve -``` diff --git a/modules/sdcore-control-plane-k8s/README.md b/modules/sdcore-control-plane-k8s/README.md new file mode 100644 index 0000000..fb0fea3 --- /dev/null +++ b/modules/sdcore-control-plane-k8s/README.md @@ -0,0 +1,65 @@ +# SD-Core Control Plane Terraform Module + +This SD-Core Control Plane Terraform module aims to deploy the [sdcore-control-plane-k8s bundle](https://charmhub.io/sdcore-control-plane-k8s) via Terraform. + +## Getting Started + +### Prerequisites + +The following software and tools needs to be installed and should be running in the local environment. + +- `microk8s` +- `juju 3.x` +- `terrafom` + +### Deploy the sdcore-control-plane-k8s bundle using Terraform + +Make sure that `storage`, `multus` and `metallb` plugins are enabled for Microk8s: + +```console +sudo microk8s enable hostpath-storage multus +sudo microk8s enable metallb:10.0.0.2-10.0.0.4 +``` + +Initialise the provider: + +```console +terraform init +``` + +Customize the configuration inputs under `terraform.tfvars` file according to requirement. + +Replace the values in the `terraform.tfvars` file. The provided model-name is not expected to pre-exist and will be created by Juju Terraform Provider. + +```yaml +# Mandatory Config Options +model_name = "put your model-name here" +``` + +Run Terraform Plan by providing var-file: + +```console +terraform plan -var-file="terraform.tfvars" +``` + +Deploy the resources, skip the approval: + +```console +terraform apply -auto-approve +``` + +### Check the Output + +Run `juju switch ` to switch to the target Juju model and observe the status of the applications. + +```console +juju status --relations +``` + +### Clean up + +Remove the applications: + +```console +terraform destroy -auto-approve +``` diff --git a/main.tf b/modules/sdcore-control-plane-k8s/main.tf similarity index 100% rename from main.tf rename to modules/sdcore-control-plane-k8s/main.tf diff --git a/terraform.tf b/modules/sdcore-control-plane-k8s/terraform.tf similarity index 83% rename from terraform.tf rename to modules/sdcore-control-plane-k8s/terraform.tf index 545a7bb..4f60bb4 100644 --- a/terraform.tf +++ b/modules/sdcore-control-plane-k8s/terraform.tf @@ -1,4 +1,4 @@ -# Copyright 2023 Canonical Ltd. +# Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. terraform { diff --git a/variables.tf b/modules/sdcore-control-plane-k8s/variables.tf similarity index 100% rename from variables.tf rename to modules/sdcore-control-plane-k8s/variables.tf diff --git a/terraform.tfvars b/terraform.tfvars deleted file mode 100644 index 4bdc551..0000000 --- a/terraform.tfvars +++ /dev/null @@ -1,17 +0,0 @@ -# Mandatory Config Options -model_name = "put your model-name here" - -# Optional Configurations -channel = "put the channel for the SD-Core charms here" -mongo-channel = "put the MongoDB charm channel here" -grafana-channel = "put the Grafana charm channel here" -cert-channel = "put the Self Signed Certificates charm channel here" -traefik-channel = "put the Self Signed Certificates charm channel here" -amf-config = {} // Put the Additional Config for the AMF charm -nssf-config = {} // Put the Additional Config for the NSSF charm -mongo-config = {} // Put the Additional Config for the MongoDB charm -grafana-config = {} // Put the Additional Config for the Grafana charm -metrics_remote_write_offer_url = "Put the Prometheus offer URL for `send-remote-write` endpoint for the Grafana" -logging_offer_url = "Put the Loki offer URL for `logging-consumer` endpoint for the Grafana" -cert-config = {} // Put the Additional Config for the Self Signed Certificates charm -traefik-config = {} // Put the Additional Config for the Traefik charm