Skip to content

Commit

Permalink
Added github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
komalsharmaaa committed May 15, 2023
1 parent 1b6936f commit bd8f0dd
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 4 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Codecov

on:
pull_request:
push:
branches:
- main

jobs:
codecov:
runs-on: ubuntu-latest

env:
TF_ACC: "1"
NSXT_MANAGER_HOST: "10.92.116.5"
NSXT_USERNAME: "admin"
NSXT_PASSWORD: "V6*IiT5VmM*+"
NSXT_ORG: "default"
NSXT_PROJECT: "Dev_project"
NSXT_VPC: "dev_vpc"
NSXT_PROJECT_INFRA_TEST_GROUP_NAME: "ORG-default-PROJECT-Dev_project-VPC-dev_vpc-default"
NSXT_PROJECT_INFRA_TEST_IP_ADDRESS_BLOCK_NAME: "ip_block_dev"
NSXT_PROJECT_INFRA_TEST_IP_ADDRESS_POOL_NAME: "_VPC_IP_ADDRESS_POOL--dev_vpc"
NSXT_PROJECT_INFRA_TEST_CONTEXT_PROFILE_NAME: "360ANTIV"
NSXT_PROJECT_INFRA_TEST_SERVICE_ID: "Active_Directory_Server"
NSXT_INFRA_TEST_GROUP_NAME: "ServiceInsertion_NSGroup"
NSXT_INFRA_TEST_IP_ADDRESS_BLOCK_NAME: "ip_block_test"
NSXT_INFRA_TEST_IP_ADDRESS_POOL_NAME: "test-ip-pool"
NSXT_INFRA_TEST_CONTEXT_PROFILE_ID: "360ANTIV"
NSXT_INFRA_TEST_SERVICE_ID: "Active_Directory_Server"
NSXT_TEST_VM_ID: "86f07fcf-46b5-40e9-8544-1a469d9c6a65"
NSXT_TEST_VM_EXTERNAL_ID: "86f07fcf-46b5-40e9-8544-1a469d9c6a65"
NSXT_TEST_VM_POWER_STATE: "VM_RUNNING"

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.4.2

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19

- name: Install dependencies
run: |
go get -v ./...
- name: Run tests and generate coverage report
run: |
TF_ACC=1 go test -v -coverprofile=coverage_report.json ./nsxt/
go tool cover -html=coverage_report.json -o coverage_report.html
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: golangci-lint
on:
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45
args: --issues-exit-code=1
only-new-issues: true
skip-pkg-cache: true
skip-build-cache: true
27 changes: 27 additions & 0 deletions .github/workflows/lifecycle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Stale issues and pull requests"
on:
schedule:
- cron: "40 17 * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 360
days-before-close: 30
exempt-issue-labels: 'needs-triage'
exempt-pr-labels: 'needs-triage'
operations-per-run: 100
stale-issue-label: 'stale'
stale-issue-message: |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.
If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!
stale-pr-label: 'stale'
stale-pr-message: |
Marking this pull request as stale due to inactivity. This helps our maintainers find and focus on the active pull requests. If this pull request receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.
If this pull request was automatically closed and you feel this pull request should be reopened, we encourage creating a new pull request linking back to this one for added context. Thank you!
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release

on:
push:
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
-
name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45
args: --issues-exit-code=1
-
name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v2
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.5.0
with:
version: latest
args: release --rm-dist --release-header .goreleaser.tmpl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
25 changes: 25 additions & 0 deletions .github/workflows/website-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: website-lint

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Install tools
run: make tools

- name: Website Lint
run: make website-lint
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ Example:

``` shell
git remote add upstream https://github.com/vmware/terraform-provider-for-vmware-nsxt-virtual-private-cloud.git
git checkout -b my-new-feature master
git checkout -b my-new-feature main
git commit -a
git push origin my-new-feature
```

### Staying In Sync With Upstream

When your branch gets out of sync with the vmware/master branch, use the following to update:
When your branch gets out of sync with the vmware/main branch, use the following to update:

``` shell
git checkout my-new-feature
git fetch -a
git pull --rebase upstream master
git pull --rebase upstream main
git push --force-with-lease origin my-new-feature
```

Expand All @@ -51,7 +51,7 @@ If you need to squash changes into an earlier commit, you can use:
``` shell
git add .
git commit --fixup <commit>
git rebase -i --autosquash master
git rebase -i --autosquash main
git push --force-with-lease origin my-new-feature
```

Expand Down

0 comments on commit bd8f0dd

Please sign in to comment.