diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..db7124a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +; https://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[{Makefile,go.mod,go.sum,*.go,.gitmodules}] +indent_style = tab +indent_size = 4 + +[*.md] +indent_size = 4 +trim_trailing_whitespace = false + +eclint_indent_style = unset diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b444581 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" diff --git a/.github/workflows/attach-artifact-release.yml b/.github/workflows/attach-artifact-release.yml new file mode 100644 index 0000000..f27cf26 --- /dev/null +++ b/.github/workflows/attach-artifact-release.yml @@ -0,0 +1,115 @@ +name: Attach Artifact to Release + +on: + pull_request: + types: + - closed + +jobs: + attach-to-release: + name: Attach Artifact to Release + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install upx + run: | + sudo apt-get update + sudo apt-get install upx + + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: '1.21.4' + + - name: Get Reusable Script Files + run: | + chmod +x release.sh + + - name: Get Artifact ID + id: get-artifact-id + run: echo "artifact_id=$(grep "vtrainVersion" "./pkg/common/utilities.go" | awk -F'"' '{print $2}')" >> $GITHUB_ENV + + - name: Backup release body + run: | + release_id=$(curl -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases?per_page=1 | jq -r '.[] | select(.name == "${{ env.artifact_id }}") | .id') + # Check if release_id is empty + if [ -z "$release_id" ]; then + echo "Release '$release_name' not found in the repository '$repo'." + exit 1 + fi + release_url="https://api.github.com/repos/${{ github.repository }}/releases/$release_id" + curl -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$release_url" | jq -r .body > release_body.txt + + - name: Store previous release body as artifact + uses: actions/upload-artifact@v2 + with: + name: release_body.txt + path: release_body.txt + + - name: Delete tag and release + uses: dev-drprasad/delete-tag-and-release@v1.0 + with: + tag_name: ${{ env.artifact_id }} + github_token: ${{ secrets.GITHUB_TOKEN }} + delete_release: true + + - name: Install dependencies + run: | + go version + go get + + - name: Generate distributions + run: sh release.sh + + - name: Upload Windows binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: vtrain_windows.zip + asset_name: vtrain_windows_$tag.zip + tag: ${{ env.artifact_id }} + overwrite: true + + - name: Upload Linux binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: vtrain_linux.zip + asset_name: vtrain_linux_$tag.zip + tag: ${{ env.artifact_id }} + overwrite: true + + - name: Upload macOS Silicon binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: vtrain_mac_arm.zip + asset_name: vtrain_mac_arm_$tag.zip + tag: ${{ env.artifact_id }} + overwrite: true + + - name: Upload macOS Intel binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: vtrain_mac_intel.zip + asset_name: vtrain_mac_intel_$tag.zip + tag: ${{ env.artifact_id }} + overwrite: true + + - name: Get latest release ID + id: get-release + run: | + LATEST_RELEASE=$(curl -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases?per_page=1" | jq -r '.[].id') + echo "Latest Release ID: $LATEST_RELEASE" + echo "RELEASE_ID=$LATEST_RELEASE" >> $GITHUB_ENV + + - name: Edit Release + uses: irongut/EditRelease@v1.2.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + id: ${{ env.RELEASE_ID }} + name: ${{ env.artifact_id }} + replacename: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..74c0137 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,44 @@ +name: Build and Test +on: + push: + branches: + - '*' + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' +jobs: + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Setup Go + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: '1.21.4' # The Go version to download (if necessary) and use. + + # Install all the dependencies + - name: Install dependencies + run: | + go version + go get + + # Run build of the application + - name: Run build + run: go build -ldflags="-s -w" . + + # Run vet & lint on the code + - name: Run vet + run: | + go vet . + + # Run testing on the code + - name: Run testing + run: go test -covermode=count -coverpkg=./pkg -coverprofile cover.out -v ./test/... \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a94c3ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +**/main +**/vtrain +jandroav/ +pulumi/ +cloud_databases.gob + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out +*.html + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# System files +**/.DS_Store + +# Editor directories and files +.vscode/ \ No newline at end of file