diff --git a/.github/actions/version/action.yml b/.github/actions/version/action.yml deleted file mode 100644 index ff323100..00000000 --- a/.github/actions/version/action.yml +++ /dev/null @@ -1,101 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - - if: ${{ inputs.download_dist == 'true' }} - uses: actions/download-artifact@v4 - with: - name: build - path: dist - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - semantic-release-license - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c509bae3..4c0874b5 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -25,6 +25,7 @@ updates: prefix: ci reviewers: - kilianpaquier + - package-ecosystem: gomod directory: / schedule: diff --git a/pkg/generate/templates/lang_golang/.github/workflows/golang.yml.tmpl b/.github/workflows/ci.yml similarity index 52% rename from pkg/generate/templates/lang_golang/.github/workflows/golang.yml.tmpl rename to .github/workflows/ci.yml index 671c20d2..10ba6711 100644 --- a/pkg/generate/templates/lang_golang/.github/workflows/golang.yml.tmpl +++ b/.github/workflows/ci.yml @@ -1,10 +1,7 @@ # Code generated by craft; DO NOT EDIT. -name: Golang -run-name: Golang - -<<- $gocli := and (gt (len .Clis) 0) (not .NoGoreleaser) >> -<<- $docker := and .Docker (gt .Binaries 0) >> +name: CICD +run-name: CICD on: pull_request: @@ -22,37 +19,75 @@ on: - development - next - staging -<<- if not .IsAutoRelease >> - main - master - - v[0-9]+.[0-9]+.x - v[0-9]+.x -<<- end >> - workflow_call: + - v[0-9]+.[0-9]+.x + workflow_dispatch: inputs: -<<- if $gocli >> - build: - description: Whether to run build job or not - required: false + dry_run: + description: Whether to run all impacting jobs in dry run or preview mode. type: boolean -<<- end >> - version: - description: Build version to use in build metadata - required: true - type: string - workflow_dispatch: -jobs: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: run-workflow: name: Run Workflow runs-on: ubuntu-latest if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} steps: - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT + run: echo "Running workflow" + + version: + name: Version + runs-on: ubuntu-latest + needs: run-workflow + if: ${{ github.event_name != 'pull_request' }} + outputs: + version: ${{ steps.version.outputs.version }} + permissions: + contents: write + issues: write + pull-requests: write + id-token: none + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: true + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + semantic-release-license + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - id: version + run: | + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then + echo "version=v${SEMREL_INFO_NEXT_VERSION#v}" >> $GITHUB_OUTPUT + else + DESCRIBE=$(git describe --tags || echo "v0.0.0") + echo "version=v${DESCRIBE#v}" >> $GITHUB_OUTPUT + fi + env: + SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} + - run: echo ${VERSION} + env: + VERSION: ${{ steps.version.outputs.version }} go-vulncheck: name: Go Vulnerability Check @@ -83,13 +118,6 @@ jobs: - uses: golangci/golangci-lint-action@v6 with: args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number -<<- if has "sonar" .CI.Options >> - - uses: actions/upload-artifact@v4 - with: - name: lint - path: reports - retention-days: 1 -<<- end >> go-test: name: Go Test @@ -102,8 +130,6 @@ jobs: - macos-latest - ubuntu-latest - windows-latest - env: - OS: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -113,9 +139,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - run: mkdir -p reports/ - run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s -<<- if has "codecov" .CI.Options >> - - if: ${{ ! startsWith(github.head_ref, 'dependabot') && ! startsWith(github.head_ref, 'renovate') }} - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v4 with: codecov_yml_path: .codecov.yml disable_search: true @@ -125,23 +149,14 @@ jobs: flags: ${{ matrix.os }} slug: ${{ github.repository }} token: ${{ secrets.CODECOV_TOKEN }} -<<- end >> -<<- if has "sonar" .CI.Options >> - - uses: actions/upload-artifact@v4 - with: - name: coverage - path: reports - retention-days: 1 -<<- end >> - -<<- if $gocli >> + env: + OS: ${{ matrix.os }} go-build: name: Go Build runs-on: ubuntu-latest - if: ${{ inputs.build }} needs: - - run-workflow + - version - go-test steps: - uses: actions/checkout@v4 @@ -151,11 +166,12 @@ jobs: go-version-file: go.mod token: ${{ secrets.GITHUB_TOKEN }} # https://github.com/marketplace/actions/goreleaser-action - - uses: goreleaser/goreleaser-action@v6 + - if: ${{ hashFiles('.goreleaser.yml') != '' }} + uses: goreleaser/goreleaser-action@v6 with: args: release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot env: - VERSION: ${{ inputs.version }} + VERSION: ${{ needs.version.outputs.version }} - uses: actions/upload-artifact@v4 with: name: build @@ -166,47 +182,43 @@ jobs: !dist/*.yaml !dist/*/ retention-days: 1 -<<- end >> - -<<- if has "sonar" .CI.Options >> - sonar-analysis: - name: Sonar Analysis + release: + name: Release runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref_protected == 'true' }} + environment: + name: release + url: ${{ github.server_url }}/${{ github.repository_owner }}/${{ github.repository }}/releases/tag/${{ steps.semrel_version.outputs.new_release_version }} needs: - - run-workflow - - go-lint - - go-test - env: - SONAR_USER_HOME: .sonar + - go-build + permissions: + contents: write + issues: write + pull-requests: write + id-token: none steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/download-artifact@v4 with: - merge-multiple: true - path: reports - - uses: actions/cache@v4 - with: - path: ${{ env.SONAR_USER_HOME }} - key: sonar-cache - - uses: sonarsource/sonarcloud-github-action@master - if: ${{ github.event_name == 'pull_request' }} - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + name: build + path: dist + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 with: - args: | - -Dproject.settings=sonar.properties - -Dsonar.pullrequest.base=${{ github.base_ref }} - -Dsonar.pullrequest.branch=${{ github.head_ref }} - -Dsonar.pullrequest.key=${{ github.event.issue.number }} - - uses: sonarsource/sonarcloud-github-action@master - if: ${{ github.event_name == 'push' }} + dry_run: ${{ inputs.dry_run == 'true' }} + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + semantic-release-license env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: | - -Dproject.settings=sonar.properties - -Dsonar.branch.name=${{ github.ref_name }} -<<- end >> \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6a8c85d1..5535d6a2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -10,7 +10,7 @@ # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. -# + name: CodeQL run-name: CodeQL diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 8bc2167f..e1c14270 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -19,7 +19,6 @@ on: - v[0-9]+.x jobs: - go-dependency-submission: name: Go Dependency Submission runs-on: ubuntu-latest diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index a729aada..8267a228 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -9,17 +9,13 @@ on: - opened - reopened - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize + - ready_for_review jobs: - labeler: name: Labeler runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected == false) }} permissions: contents: read # enfore rights to specify no release, even draft, is created pull-requests: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1098c56d..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,77 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - permissions: - contents: write - issues: write - pull-requests: write - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - uses: actions/checkout@v4 - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - golang: - name: Golang - needs: version - uses: ./.github/workflows/golang.yml - permissions: - checks: write - with: - build: true - version: ${{ needs.version.outputs.version }} - secrets: inherit - - release: - name: Release - runs-on: ubuntu-latest - environment: release - permissions: - contents: write - issues: write - pull-requests: write - needs: - - version - - golang - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.releaserc.yml b/.releaserc.yml index d3625669..115db523 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -89,6 +89,4 @@ plugins: assets: - label: CHANGELOG.md path: CHANGELOG.md - - path: checksums.txt - - path: dist - - "@semantic-release/exec" \ No newline at end of file + - path: dist \ No newline at end of file diff --git a/examples/generic_github/.github/actions/version/action.yml b/examples/generic_github/.github/actions/version/action.yml deleted file mode 100644 index 4670c18e..00000000 --- a/examples/generic_github/.github/actions/version/action.yml +++ /dev/null @@ -1,95 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/examples/generic_github/.github/workflows/ci.yml b/examples/generic_github/.github/workflows/ci.yml new file mode 100644 index 00000000..e7bb051e --- /dev/null +++ b/examples/generic_github/.github/workflows/ci.yml @@ -0,0 +1,81 @@ +# Code generated by craft; DO NOT EDIT. + +name: CICD +run-name: CICD + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + push: + branches: + - alpha + - beta + - dev + - develop + - development + - next + - staging + - main + - master + - v[0-9]+.x + - v[0-9]+.[0-9]+.x + workflow_dispatch: + inputs: + dry_run: + description: Whether to run all impacting jobs in dry run or preview mode. + type: boolean + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + run-workflow: + name: Run Workflow + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} + steps: + - id: skip + run: echo "Running workflow" + + release: + name: Release + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref_protected == 'true' }} + environment: + name: release + url: ${{ github.server_url }}/${{ github.repository_owner }}/${{ github.repository }}/releases/tag/${{ steps.semrel_version.outputs.new_release_version }} + needs: + permissions: + id-token: none + steps: + - id: app_token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.RELEASE_APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.app_token.outputs.token }} + persist-credentials: false + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: ${{ inputs.dry_run == 'true' }} + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + env: + GITHUB_TOKEN: ${{ steps.app_token.outputs.token }} \ No newline at end of file diff --git a/testdata/golang/success_options_github/.github/workflows/dependencies.yml b/examples/generic_github/.github/workflows/dependencies.yml similarity index 99% rename from testdata/golang/success_options_github/.github/workflows/dependencies.yml rename to examples/generic_github/.github/workflows/dependencies.yml index 8bc2167f..e1c14270 100644 --- a/testdata/golang/success_options_github/.github/workflows/dependencies.yml +++ b/examples/generic_github/.github/workflows/dependencies.yml @@ -19,7 +19,6 @@ on: - v[0-9]+.x jobs: - go-dependency-submission: name: Go Dependency Submission runs-on: ubuntu-latest diff --git a/examples/generic_github/.github/workflows/release.yml b/examples/generic_github/.github/workflows/release.yml deleted file mode 100644 index 2eda5eb2..00000000 --- a/examples/generic_github/.github/workflows/release.yml +++ /dev/null @@ -1,73 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - id: app_token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.RELEASE_APP_ID }} - private-key: ${{ secrets.PRIVATE_KEY }} - - uses: actions/checkout@v4 - with: - token: ${{ steps.app_token.outputs.token }} - persist-credentials: false - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ steps.app_token.outputs.token }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - release: - name: Release - runs-on: ubuntu-latest - environment: release - needs: - - version - steps: - - id: app_token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.RELEASE_APP_ID }} - private-key: ${{ secrets.PRIVATE_KEY }} - - uses: actions/checkout@v4 - with: - token: ${{ steps.app_token.outputs.token }} - persist-credentials: false - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ steps.app_token.outputs.token }} \ No newline at end of file diff --git a/examples/generic_github/.github/workflows/renovate.yml b/examples/generic_github/.github/workflows/renovate.yml index 931d4aa9..d48dffd9 100644 --- a/examples/generic_github/.github/workflows/renovate.yml +++ b/examples/generic_github/.github/workflows/renovate.yml @@ -7,14 +7,13 @@ on: workflow_dispatch: inputs: dry_run: - description: Dry run + description: Whether to only run renovate job in dry run mode or let renovate create pull requests. type: boolean default: false schedule: - cron: "0 12 * * *" jobs: - renovate: name: Renovate runs-on: ubuntu-latest diff --git a/examples/generic_github/.gitignore b/examples/generic_github/.gitignore new file mode 100644 index 00000000..036260d8 --- /dev/null +++ b/examples/generic_github/.gitignore @@ -0,0 +1 @@ +# Code generated by craft; DO NOT EDIT. \ No newline at end of file diff --git a/examples/generic_github/.releaserc.yml b/examples/generic_github/.releaserc.yml index 0d4b7220..d44ce020 100644 --- a/examples/generic_github/.releaserc.yml +++ b/examples/generic_github/.releaserc.yml @@ -86,5 +86,4 @@ plugins: successCommentCondition: <% return true; %> assets: - label: CHANGELOG.md - path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file + path: CHANGELOG.md \ No newline at end of file diff --git a/examples/generic_github/renovate.json5 b/examples/generic_github/renovate.json5 index c72eaaf5..701e51ed 100644 --- a/examples/generic_github/renovate.json5 +++ b/examples/generic_github/renovate.json5 @@ -107,101 +107,5 @@ "matchCategories": [ "ci" ], "matchUpdateTypes": [ "major" ] }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "golang dependencies (non major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "golang dependencies (major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "js dependencies (non major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "js dependencies (major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "major" ] - }, ], } \ No newline at end of file diff --git a/examples/generic_gitlab/.gitignore b/examples/generic_gitlab/.gitignore new file mode 100644 index 00000000..036260d8 --- /dev/null +++ b/examples/generic_gitlab/.gitignore @@ -0,0 +1 @@ +# Code generated by craft; DO NOT EDIT. \ No newline at end of file diff --git a/examples/generic_gitlab/.gitlab-ci.yml b/examples/generic_gitlab/.gitlab-ci.yml index 37bcd914..2972d984 100644 --- a/examples/generic_gitlab/.gitlab-ci.yml +++ b/examples/generic_gitlab/.gitlab-ci.yml @@ -1,5 +1,4 @@ # Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. --- include: .gitlab/workflows/.gitlab-ci.yml diff --git a/examples/generic_gitlab/.gitlab/workflows/.gitlab-ci.yml b/examples/generic_gitlab/.gitlab/workflows/.gitlab-ci.yml index 3791b5b5..80673910 100644 --- a/examples/generic_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ b/examples/generic_gitlab/.gitlab/workflows/.gitlab-ci.yml @@ -21,35 +21,24 @@ variables: SEMREL_AUTO_RELEASE_ENABLED: "false" semantic-release-info: + variables: + GIT_DEPTH: "0" after_script: - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then + echo "BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8)" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi + else + DESCRIBE=$(git describe --tags || echo "v1.0.0") + echo "SEMREL_INFO_NEXT_VERSION=v${DESCRIBE#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" fi + - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" \ No newline at end of file +semantic-release: + variables: + GIT_DEPTH: "0" \ No newline at end of file diff --git a/examples/generic_gitlab/.releaserc.yml b/examples/generic_gitlab/.releaserc.yml index eb605248..06b83d6f 100644 --- a/examples/generic_gitlab/.releaserc.yml +++ b/examples/generic_gitlab/.releaserc.yml @@ -85,5 +85,4 @@ plugins: successCommentCondition: <% return true; %> assets: - label: CHANGELOG.md - path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file + path: CHANGELOG.md \ No newline at end of file diff --git a/examples/golang_github/.dockerignore b/examples/golang_github/.dockerignore index 7923e634..05efcb81 100644 --- a/examples/golang_github/.dockerignore +++ b/examples/golang_github/.dockerignore @@ -20,6 +20,9 @@ docs/ reports/ dist/ +# vendor dependencies +vendor/ + # binaries cron-* !cron-*/ @@ -28,7 +31,4 @@ worker-* # test files **/*_test.go -**/*.test - -# vendor dependencies -vendor/ \ No newline at end of file +**/*.test \ No newline at end of file diff --git a/examples/golang_github/.github/actions/docker/action.yml b/examples/golang_github/.github/actions/docker/action.yml new file mode 100644 index 00000000..18f74f8e --- /dev/null +++ b/examples/golang_github/.github/actions/docker/action.yml @@ -0,0 +1,115 @@ +# Code generated by craft; DO NOT EDIT. + +name: Docker +description: Run hadolint on Dockerfile, build the docker image, deploys it and then run trivy security analysis on it + +inputs: + registry: + default: "" + description: Docker registry on which push the docker image. By default it will be Docker Hub. + image: + description: Full docker image name (without registry). By default it will be github.repository value. + version: + description: Docker image version. + required: true + registry_token: + description: Docker registry access token. + required: true + +runs: + using: composite + steps: + - uses: actions/checkout@v4 + + ######################################################## + # Hadolint + ######################################################## + + - uses: hadolint/hadolint-action@v3.1.0 + with: + format: sarif + output-file: hadolint-results.sarif + - if: ${{ ! cancelled() }} + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: hadolint-results.sarif + category: docker-hadolint + - id: hadolint + if: ${{ ! cancelled() }} + uses: hadolint/hadolint-action@v3.1.0 + with: + format: tty + + ######################################################## + # Build + ######################################################## + + - id: image + shell: bash + run: | + : "${DOCKER_IMAGE:=${GITHUB_REPOSIORY}}" + image="$([ "${DOCKER_REGISTRY}" != "" ] && echo "${DOCKER_REGISTRY}/${DOCKER_IMAGE}" || echo "${DOCKER_IMAGE}")" + echo "Building docker image with full name '${image}'" + echo "image=${image}" >> $GITHUB_OUTPUT + env: + DOCKER_IMAGE: ${{ inputs.image }} + DOCKER_REGISTRY: ${{ inputs.registry }} + # https://github.com/marketplace/actions/docker-metadata-action + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image.outputs.image }} + labels: | + org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} + org.opencontainers.image.ref.name=${{ github.ref_name }} + org.opencontainers.image.version=${{ inputs.version }} + org.opencontainers.image.revision=${{ github.sha }} + tags: | + type=raw,enable={{is_default_branch}},value=latest + type=semver,enable=true,pattern={{raw}},value=${{ inputs.version }} + type=semver,enable=${{ github.ref_type == 'tag' }},pattern=v{{major}}.{{minor}},value=${{ inputs.version }} + type=semver,enable=${{ github.ref_type == 'tag' }},pattern=v{{major}},value=${{ inputs.version }} + # https://github.com/marketplace/actions/docker-setup-buildx + - uses: docker/setup-buildx-action@v3 + # https://github.com/marketplace/actions/docker-login + - uses: docker/login-action@v3 + with: + registry: ${{ inputs.registry }} + username: ${{ github.repository_owner }} + password: ${{ inputs.registry_token }} + # https://github.com/marketplace/actions/build-and-push-docker-images + - uses: docker/build-push-action@v6 + with: + context: . + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + + ######################################################## + # Trivy + ######################################################## + + - uses: aquasecurity/trivy-action@master + with: + format: sarif + ignore-unfixed: false + image-ref: ${{ steps.image.outputs.image }}:${{ inputs.version }} + output: trivy-results.sarif + severity: MEDIUM,HIGH,CRITICAL + env: + TRIVY_USERNAME: ${{ github.repository_owner }} + TRIVY_PASSWORD: ${{ inputs.registry_token }} + - uses: github/codeql-action/upload-sarif@v3 + with: + category: docker-trivy + sarif_file: trivy-results.sarif + - uses: aquasecurity/trivy-action@master + with: + exit-code: "1" + ignore-unfixed: false + image-ref: ${{ steps.image.outputs.image }}:${{ inputs.version }} + severity: MEDIUM,HIGH,CRITICAL + env: + TRIVY_USERNAME: ${{ github.repository_owner }} + TRIVY_PASSWORD: ${{ inputs.registry_token }} \ No newline at end of file diff --git a/examples/golang_github/.github/actions/version/action.yml b/examples/golang_github/.github/actions/version/action.yml deleted file mode 100644 index f47a3641..00000000 --- a/examples/golang_github/.github/actions/version/action.yml +++ /dev/null @@ -1,96 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - semantic-release-license - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/examples/golang_github/.github/dependabot.yml b/examples/golang_github/.github/dependabot.yml index 18cd16bf..6276e7ef 100644 --- a/examples/golang_github/.github/dependabot.yml +++ b/examples/golang_github/.github/dependabot.yml @@ -25,6 +25,7 @@ updates: prefix: ci reviewers: - kilianpaquier + - package-ecosystem: docker directory: / schedule: @@ -41,6 +42,7 @@ updates: prefix: chore reviewers: - kilianpaquier + - package-ecosystem: gomod directory: / schedule: diff --git a/examples/golang_github/.github/workflows/ci.yml b/examples/golang_github/.github/workflows/ci.yml new file mode 100644 index 00000000..5993e191 --- /dev/null +++ b/examples/golang_github/.github/workflows/ci.yml @@ -0,0 +1,362 @@ +# Code generated by craft; DO NOT EDIT. + +name: CICD +run-name: CICD + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + push: + branches: + - alpha + - beta + - dev + - develop + - development + - next + - staging + - main + - master + - v[0-9]+.x + - v[0-9]+.[0-9]+.x + workflow_dispatch: + inputs: + dry_run: + description: Whether to run all impacting jobs in dry run or preview mode. + type: boolean + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + run-workflow: + name: Run Workflow + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} + steps: + - id: skip + run: echo "Running workflow" + + version: + name: Version + runs-on: ubuntu-latest + needs: run-workflow + if: ${{ github.event_name != 'pull_request' }} + outputs: + version: ${{ steps.version.outputs.version }} + permissions: + contents: write + issues: write + pull-requests: write + id-token: none + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: true + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + semantic-release-license + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - id: version + run: | + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then + echo "version=v${SEMREL_INFO_NEXT_VERSION#v}" >> $GITHUB_OUTPUT + else + DESCRIBE=$(git describe --tags || echo "v0.0.0") + echo "version=v${DESCRIBE#v}" >> $GITHUB_OUTPUT + fi + env: + SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} + - run: echo ${VERSION} + env: + VERSION: ${{ steps.version.outputs.version }} + + go-vulncheck: + name: Go Vulnerability Check + runs-on: ubuntu-latest + needs: run-workflow + steps: + - uses: golang/govulncheck-action@v1 + with: + check-latest: true + go-package: ./... + go-version-file: go.mod + + go-lint: + name: Go Lint + runs-on: ubuntu-latest + needs: run-workflow + permissions: + checks: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + cache: false + check-latest: true + go-version-file: go.mod + token: ${{ secrets.GITHUB_TOKEN }} + - run: mkdir -p reports/ + - uses: golangci/golangci-lint-action@v6 + with: + args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number + - uses: actions/upload-artifact@v4 + with: + name: lint + path: reports + retention-days: 1 + + go-test: + name: Go Test + runs-on: ${{ matrix.os }} + needs: run-workflow + strategy: + fail-fast: false + matrix: + os: + - macos-latest + - ubuntu-latest + - windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + check-latest: true + go-version-file: go.mod + token: ${{ secrets.GITHUB_TOKEN }} + - run: mkdir -p reports/ + - run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s + - uses: codecov/codecov-action@v4 + with: + codecov_yml_path: .codecov.yml + disable_search: true + env_vars: OS + fail_ci_if_error: false + files: reports/go-coverage.native.out + flags: ${{ matrix.os }} + slug: ${{ github.repository }} + token: ${{ secrets.CODECOV_TOKEN }} + env: + OS: ${{ matrix.os }} + - uses: actions/upload-artifact@v4 + with: + name: coverage + path: reports + retention-days: 1 + + go-build: + name: Go Build + runs-on: ubuntu-latest + needs: + - version + - go-test + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + check-latest: true + go-version-file: go.mod + token: ${{ secrets.GITHUB_TOKEN }} + # https://github.com/marketplace/actions/goreleaser-action + - if: ${{ hashFiles('.goreleaser.yml') != '' }} + uses: goreleaser/goreleaser-action@v6 + with: + args: release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot + env: + VERSION: ${{ needs.version.outputs.version }} + - uses: actions/upload-artifact@v4 + with: + name: build + # order is important to filter unwanted globs after the filter or desired globs + path: | + dist/* + !dist/*.json + !dist/*.yaml + !dist/*/ + retention-days: 1 + + sonar-analysis: + name: Sonar Analysis + runs-on: ubuntu-latest + needs: + - go-lint + - go-test + env: + SONAR_USER_HOME: .sonar + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: reports + - uses: actions/cache@v4 + with: + path: ${{ env.SONAR_USER_HOME }} + key: sonar-cache + - if: ${{ github.event_name == 'pull_request' }} + uses: sonarsource/sonarcloud-github-action@master + with: + args: | + -Dproject.settings=sonar.properties + -Dsonar.pullrequest.base=${{ github.base_ref }} + -Dsonar.pullrequest.branch=${{ github.head_ref }} + -Dsonar.pullrequest.key=${{ github.event.issue.number }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - if: ${{ github.event_name == 'push' }} + uses: sonarsource/sonarcloud-github-action@master + with: + args: | + -Dproject.settings=sonar.properties + -Dsonar.branch.name=${{ github.ref_name }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + docker-hadolint: + name: Docker Hadolint + runs-on: ubuntu-latest + needs: run-workflow + permissions: + pull-requests: write + security-events: write + steps: + - uses: actions/checkout@v4 + - uses: hadolint/hadolint-action@v3.1.0 + continue-on-error: true # ensure sarif and tty formats are run for CodeQL and logs observability + with: + format: sarif + output-file: hadolint-results.sarif + - uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: hadolint-results.sarif + category: docker-hadolint + + docker-build: + name: Docker Build + runs-on: ubuntu-latest + needs: + - version + - go-test + environment: + name: docker + url: ${{ steps.image.outputs.full_image }} + permissions: + packages: write + security-events: write + steps: + - uses: actions/checkout@v4 + - id: image + run: | + image="$([ "${DOCKER_REGISTRY}" != "" ] && echo "${DOCKER_REGISTRY}/${GITHUB_REPOSIORY}" || echo "${GITHUB_REPOSIORY}")" + echo "Building docker image with full name '${image}'" + echo "image=${image}" >> $GITHUB_OUTPUT + + echo "full_image=${image}:${IMAGE_VERSION}" >> $GITHUB_OUTPUT + if [[ "${IMAGE_VERSION#v}" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then + echo "stable=true" >> $GITHUB_OUTPUT + fi + env: + DOCKER_REGISTRY: ghcr.io + IMAGE_VERSION: ${{ needs.version.outputs.version }} + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image.outputs.image }} + labels: | + org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} + org.opencontainers.image.ref.name=${{ github.ref_name }} + org.opencontainers.image.version=${{ needs.version.outputs.version }} + org.opencontainers.image.revision=${{ github.sha }} + tags: | + type=raw,enable={{is_default_branch}},value=latest + type=semver,enable=true,pattern={{raw}},value=${{ needs.version.outputs.version }} + type=semver,enable=${{ steps.image.outputs.stable == 'true' }},pattern=v{{major}}.{{minor}},value=${{ needs.version.outputs.version }} + type=semver,enable=${{ steps.image.outputs.stable == 'true' }},pattern=v{{major}},value=${{ needs.version.outputs.version }} + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v6 + with: + context: . + labels: ${{ steps.meta.outputs.labels }} + push: true + tags: ${{ steps.meta.outputs.tags }} + - uses: aquasecurity/trivy-action@master + with: + exit-code: 0 + format: sarif + ignore-unfixed: false + image-ref: ${{ steps.image.outputs.full_image }} + output: trivy-results.sarif + severity: MEDIUM,HIGH,CRITICAL + env: + TRIVY_USERNAME: ${{ github.repository_owner }} + TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + - uses: github/codeql-action/upload-sarif@v3 + with: + category: docker-trivy + sarif_file: trivy-results.sarif + + release: + name: Release + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref_protected == 'true' }} + environment: + name: release + url: ${{ github.server_url }}/${{ github.repository_owner }}/${{ github.repository }}/releases/tag/${{ steps.semrel_version.outputs.new_release_version }} + needs: + - go-build + - docker-build + permissions: + contents: write + issues: write + pull-requests: write + id-token: none + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v4 + with: + name: build + path: dist + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: ${{ inputs.dry_run == 'true' }} + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + semantic-release-license + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/examples/golang_github/.github/workflows/codeql.yml b/examples/golang_github/.github/workflows/codeql.yml index 6a8c85d1..5535d6a2 100644 --- a/examples/golang_github/.github/workflows/codeql.yml +++ b/examples/golang_github/.github/workflows/codeql.yml @@ -10,7 +10,7 @@ # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. -# + name: CodeQL run-name: CodeQL diff --git a/examples/golang_github/.github/workflows/dependencies.yml b/examples/golang_github/.github/workflows/dependencies.yml index 8bc2167f..e1c14270 100644 --- a/examples/golang_github/.github/workflows/dependencies.yml +++ b/examples/golang_github/.github/workflows/dependencies.yml @@ -19,7 +19,6 @@ on: - v[0-9]+.x jobs: - go-dependency-submission: name: Go Dependency Submission runs-on: ubuntu-latest diff --git a/examples/golang_github/.github/workflows/docker.yml b/examples/golang_github/.github/workflows/docker.yml deleted file mode 100644 index e5ac11ff..00000000 --- a/examples/golang_github/.github/workflows/docker.yml +++ /dev/null @@ -1,177 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Docker -run-name: Docker - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - workflow_call: - inputs: - release: - description: Whether the docker built image must be propagated to major and minor tags or not - required: false - type: boolean - version: - description: The docker tag to build - required: false - type: string - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - version: - name: Version - runs-on: ubuntu-latest - environment: release - needs: run-workflow - if: ${{ github.event_name != 'pull_request' }} - permissions: - contents: write - issues: write - pull-requests: write - outputs: - release: ${{ steps.version_merge.outputs.release }} - version: ${{ steps.version_merge.outputs.version }} - steps: - - uses: actions/checkout@v4 - - id: version - if: ${{ github.event_name == 'workflow_dispatch' }} - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} - - id: version_merge - run: | - if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then - echo "release=${RELEASE}" >> $GITHUB_OUTPUT - echo "version=${VERSION}" >> $GITHUB_OUTPUT - exit 0 - fi - echo "release=${INPUTS_RELEASE}" >> $GITHUB_OUTPUT - echo "version=${INPUTS_VERSION}" >> $GITHUB_OUTPUT - env: - VERSION: ${{ steps.version.outputs.version }} - RELEASE: ${{ steps.version.outputs.release }} - INPUTS_VERSION: ${{ inputs.version }} - INPUTS_RELEASE: ${{ inputs.release }} - - docker-hadolint: - name: Docker Hadolint - runs-on: ubuntu-latest - needs: run-workflow - permissions: - pull-requests: write - security-events: write - steps: - - uses: actions/checkout@v4 - - uses: hadolint/hadolint-action@v3.1.0 - with: - format: sarif - output-file: hadolint-results.sarif - - if: ${{ ! cancelled() }} - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: hadolint-results.sarif - category: docker-hadolint - - id: hadolint - if: ${{ ! cancelled() }} - uses: hadolint/hadolint-action@v3.1.0 - with: - format: tty - - docker-build: - name: Docker Build - runs-on: ubuntu-latest - environment: docker - needs: - - run-workflow - - version - outputs: - image: ${{ steps.image.outputs.image }} - steps: - - uses: actions/checkout@v4 - - id: image - run: | - IMAGE="ghcr.io/$GITHUB_REPOSITORY" - if [ "$RELEASE" != "true" ]; then - IMAGE="$IMAGE/snapshot" - fi - echo "image=$IMAGE" >> $GITHUB_OUTPUT - env: - RELEASE: ${{ needs.version.outputs.release }} - - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ steps.image.outputs.image }} - labels: | - org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} - org.opencontainers.image.ref.name="${{ github.ref_name }}" - org.opencontainers.image.version="${{ needs.version.outputs.version }}" - org.opencontainers.image.revision="${{ github.sha }}" - tags: | - type=raw,enable={{is_default_branch}},value=latest - type=semver,enable=true,pattern={{raw}},value=${{ needs.version.outputs.version }} - type=semver,enable=${{ needs.version.outputs.release }},pattern=v{{major}}.{{minor}},value=${{ needs.version.outputs.version }} - type=semver,enable=${{ needs.version.outputs.release }},pattern=v{{major}},value=${{ needs.version.outputs.version }} - - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.REGISTRY_TOKEN }} - - uses: docker/build-push-action@v6 - with: - context: . - labels: ${{ steps.meta.outputs.labels }} - push: true - tags: ${{ steps.meta.outputs.tags }} - - docker-trivy: - name: Docker Trivy - runs-on: ubuntu-latest - environment: docker - permissions: - security-events: write - needs: - - run-workflow - - version - - docker-build - steps: - - uses: aquasecurity/trivy-action@master - with: - format: sarif - ignore-unfixed: false - image-ref: "${{ needs.docker-build.outputs.image }}:${{ needs.version.outputs.version }}" - output: trivy-results.sarif - severity: MEDIUM,HIGH,CRITICAL - env: - TRIVY_USERNAME: ${{ github.repository_owner }} - TRIVY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} - - uses: github/codeql-action/upload-sarif@v3 - with: - category: docker-trivy - sarif_file: trivy-results.sarif - - uses: aquasecurity/trivy-action@master - with: - exit-code: "1" - ignore-unfixed: false - image-ref: "${{ needs.docker-build.outputs.image }}:${{ needs.version.outputs.version }}" - severity: MEDIUM,HIGH,CRITICAL - env: - TRIVY_USERNAME: ${{ github.repository_owner }} - TRIVY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} \ No newline at end of file diff --git a/examples/golang_github/.github/workflows/golang.yml b/examples/golang_github/.github/workflows/golang.yml index b51f4429..d0e53690 100644 --- a/examples/golang_github/.github/workflows/golang.yml +++ b/examples/golang_github/.github/workflows/golang.yml @@ -4,49 +4,22 @@ name: Golang run-name: Golang on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x workflow_call: inputs: version: - description: Build version to use in build metadata + description: Build version to use in build metadata. + required: true + type: string + event_name: + description: GitHub Actions real event_name since it will always 'workflow_dispatch' by default. required: true type: string - workflow_dispatch: jobs: - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - go-vulncheck: name: Go Vulnerability Check runs-on: ubuntu-latest - needs: run-workflow steps: - uses: golang/govulncheck-action@v1 with: @@ -57,7 +30,6 @@ jobs: go-lint: name: Go Lint runs-on: ubuntu-latest - needs: run-workflow permissions: checks: write steps: @@ -81,7 +53,6 @@ jobs: go-test: name: Go Test runs-on: ${{ matrix.os }} - needs: run-workflow strategy: fail-fast: false matrix: @@ -100,8 +71,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - run: mkdir -p reports/ - run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - - if: ${{ ! startsWith(github.head_ref, 'dependabot') && ! startsWith(github.head_ref, 'renovate') }} - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v4 with: codecov_yml_path: .codecov.yml disable_search: true @@ -117,11 +87,40 @@ jobs: path: reports retention-days: 1 + go-build: + name: Go Build + runs-on: ubuntu-latest + needs: + - go-test + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + check-latest: true + go-version-file: go.mod + token: ${{ secrets.GITHUB_TOKEN }} + # https://github.com/marketplace/actions/goreleaser-action + - if: ${{ hashFiles('.goreleaser.yml') != '' }} + uses: goreleaser/goreleaser-action@v6 + with: + args: release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot + env: + VERSION: ${{ inputs.version }} + - uses: actions/upload-artifact@v4 + with: + name: build + # order is important to filter unwanted globs after the filter or desired globs + path: | + dist/* + !dist/*.json + !dist/*.yaml + !dist/*/ + retention-days: 1 + sonar-analysis: name: Sonar Analysis runs-on: ubuntu-latest needs: - - run-workflow - go-lint - go-test env: @@ -138,21 +137,21 @@ jobs: with: path: ${{ env.SONAR_USER_HOME }} key: sonar-cache - - uses: sonarsource/sonarcloud-github-action@master - if: ${{ github.event_name == 'pull_request' }} - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - if: ${{ inputs.event_name == 'pull_request' }} + uses: sonarsource/sonarcloud-github-action@master with: args: | -Dproject.settings=sonar.properties -Dsonar.pullrequest.base=${{ github.base_ref }} -Dsonar.pullrequest.branch=${{ github.head_ref }} -Dsonar.pullrequest.key=${{ github.event.issue.number }} - - uses: sonarsource/sonarcloud-github-action@master - if: ${{ github.event_name == 'push' }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - if: ${{ inputs.event_name == 'push' }} + uses: sonarsource/sonarcloud-github-action@master with: args: | -Dproject.settings=sonar.properties - -Dsonar.branch.name=${{ github.ref_name }} \ No newline at end of file + -Dsonar.branch.name=${{ github.ref_name }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/examples/golang_github/.github/workflows/labeler.yml b/examples/golang_github/.github/workflows/labeler.yml index a729aada..8267a228 100644 --- a/examples/golang_github/.github/workflows/labeler.yml +++ b/examples/golang_github/.github/workflows/labeler.yml @@ -9,17 +9,13 @@ on: - opened - reopened - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize + - ready_for_review jobs: - labeler: name: Labeler runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected == false) }} permissions: contents: read # enfore rights to specify no release, even draft, is created pull-requests: write diff --git a/examples/golang_github/.github/workflows/release.yml b/examples/golang_github/.github/workflows/release.yml deleted file mode 100644 index e2ac2066..00000000 --- a/examples/golang_github/.github/workflows/release.yml +++ /dev/null @@ -1,91 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - permissions: - contents: write - issues: write - pull-requests: write - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - uses: actions/checkout@v4 - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - golang: - name: Golang - needs: version - uses: ./.github/workflows/golang.yml - permissions: - checks: write - with: - version: ${{ needs.version.outputs.version }} - secrets: inherit - - docker: - name: Docker - needs: version - uses: ./.github/workflows/docker.yml - permissions: - contents: write - issues: write - pull-requests: write - security-events: write - with: - version: ${{ needs.version.outputs.version }} - release: ${{ needs.version.outputs.release == 'true' }} - secrets: inherit - - release: - name: Release - runs-on: ubuntu-latest - environment: release - permissions: - contents: write - issues: write - pull-requests: write - needs: - - version - - golang - - docker - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/examples/golang_github/.releaserc.yml b/examples/golang_github/.releaserc.yml index d5afe7b3..115db523 100644 --- a/examples/golang_github/.releaserc.yml +++ b/examples/golang_github/.releaserc.yml @@ -89,4 +89,4 @@ plugins: assets: - label: CHANGELOG.md path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file + - path: dist \ No newline at end of file diff --git a/examples/golang_github/sonar.properties b/examples/golang_github/sonar.properties index 15ce1cb1..3231dee7 100644 --- a/examples/golang_github/sonar.properties +++ b/examples/golang_github/sonar.properties @@ -9,7 +9,7 @@ sonar.projectKey=kilianpaquier_craft_examples_golang_github sonar.projectName=golang_github sonar.exclusions=**/examples/**,**/testdata/**,**/vendor/** -sonar.coverage.exclusions=cmd/**,**/cobra/**,**/tests/**,**/testutils/** sonar.test.inclusions=**/*_test.go +sonar.coverage.exclusions=cmd/**,**/cobra/**,**/tests/**,**/testutils/** sonar.go.coverage.reportPaths=reports/go-coverage.native.out sonar.go.golangci-lint.reportPaths=reports/go-ci-lint.checkstyle.xml \ No newline at end of file diff --git a/examples/golang_gitlab/.dockerignore b/examples/golang_gitlab/.dockerignore index 42396729..9efc1fe8 100644 --- a/examples/golang_gitlab/.dockerignore +++ b/examples/golang_gitlab/.dockerignore @@ -20,13 +20,13 @@ docs/ reports/ dist/ +# vendor dependencies +vendor/ + # binaries worker-* !worker-*/ # test files **/*_test.go -**/*.test - -# vendor dependencies -vendor/ \ No newline at end of file +**/*.test \ No newline at end of file diff --git a/examples/golang_gitlab/.gitlab-ci.yml b/examples/golang_gitlab/.gitlab-ci.yml index 147fbb70..cb2d639c 100644 --- a/examples/golang_gitlab/.gitlab-ci.yml +++ b/examples/golang_gitlab/.gitlab-ci.yml @@ -1,5 +1,4 @@ # Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. --- include: .gitlab/workflows/.gitlab-ci.yml diff --git a/examples/golang_gitlab/.gitlab/workflows/.gitlab-ci.yml b/examples/golang_gitlab/.gitlab/workflows/.gitlab-ci.yml index 1bdcdcc0..02b58be7 100644 --- a/examples/golang_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ b/examples/golang_gitlab/.gitlab/workflows/.gitlab-ci.yml @@ -77,41 +77,46 @@ variables: SEMREL_AUTO_RELEASE_ENABLED: "false" semantic-release-info: + variables: + GIT_DEPTH: "0" after_script: - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then + echo "BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8)" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 + else + DESCRIBE=$(git describe --tags || echo "v1.0.0") + echo "SEMREL_INFO_NEXT_VERSION=v${DESCRIBE#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" +semantic-release: + variables: + GIT_DEPTH: "0" + go-build: - when: never + image: ghcr.io/goreleaser/goreleaser:latest + rules: + # https://gitlab.com/to-be-continuous/golang/-/blob/master/templates/gitlab-ci-golang.yml?ref_type=heads#L651 + - if: $GO_TEST_IMAGE != "" + exists: + - .goreleaser.yml + script: + - goreleaser release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot + artifacts: + name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" + paths: + - dist/ + exclude: + - dist/*.json + - dist/*.yaml + - dist/*/ + expire_in: 1 day .renovate-rules: &renovate-rules rules: diff --git a/examples/golang_gitlab/.releaserc.yml b/examples/golang_gitlab/.releaserc.yml index 5db47095..71a4a40b 100644 --- a/examples/golang_gitlab/.releaserc.yml +++ b/examples/golang_gitlab/.releaserc.yml @@ -88,4 +88,4 @@ plugins: assets: - label: CHANGELOG.md path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file + - path: dist \ No newline at end of file diff --git a/examples/golang_gitlab/renovate.json5 b/examples/golang_gitlab/renovate.json5 index c72eaaf5..01fa7431 100644 --- a/examples/golang_gitlab/renovate.json5 +++ b/examples/golang_gitlab/renovate.json5 @@ -107,18 +107,6 @@ "matchCategories": [ "ci" ], "matchUpdateTypes": [ "major" ] }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, { "addLabels": [ "non-major" ], "groupName": "golang dependencies (non major)", @@ -133,74 +121,14 @@ }, { "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "js dependencies (non major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "js dependencies (major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], + "groupName": "docker dependencies (non major)", + "matchCategories": [ "docker" ], "matchUpdateTypes": [ "!major" ] }, { "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], + "groupName": "docker dependencies (major)", + "matchCategories": [ "docker" ], "matchUpdateTypes": [ "major" ] }, ], diff --git a/examples/golang_gitlab/sonar.properties b/examples/golang_gitlab/sonar.properties index 99a51a91..59086f90 100644 --- a/examples/golang_gitlab/sonar.properties +++ b/examples/golang_gitlab/sonar.properties @@ -9,8 +9,8 @@ sonar.projectKey=kilianpaquier_craft_examples_golang_gitlab sonar.projectName=golang_gitlab sonar.exclusions=**/examples/**,**/testdata/**,**/vendor/** -sonar.coverage.exclusions=cmd/**,**/cobra/**,**/tests/**,**/testutils/** sonar.test.inclusions=**/*_test.go +sonar.coverage.exclusions=cmd/**,**/cobra/**,**/tests/**,**/testutils/** sonar.go.tests.reportPaths=reports/go-test.native.json sonar.go.coverage.reportPaths=reports/go-coverage.native.out diff --git a/examples/helm/.gitignore b/examples/helm/.gitignore new file mode 100644 index 00000000..036260d8 --- /dev/null +++ b/examples/helm/.gitignore @@ -0,0 +1 @@ +# Code generated by craft; DO NOT EDIT. \ No newline at end of file diff --git a/examples/hugo_github/.github/actions/version/action.yml b/examples/hugo_github/.github/actions/version/action.yml deleted file mode 100644 index f47a3641..00000000 --- a/examples/hugo_github/.github/actions/version/action.yml +++ /dev/null @@ -1,96 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - semantic-release-license - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/examples/hugo_github/.github/workflows/ci.yml b/examples/hugo_github/.github/workflows/ci.yml new file mode 100644 index 00000000..98849d05 --- /dev/null +++ b/examples/hugo_github/.github/workflows/ci.yml @@ -0,0 +1,175 @@ +# Code generated by craft; DO NOT EDIT. + +name: CICD +run-name: CICD + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + push: + branches: + - alpha + - beta + - dev + - develop + - development + - next + - staging + - main + - master + - v[0-9]+.x + - v[0-9]+.[0-9]+.x + workflow_dispatch: + inputs: + dry_run: + description: Whether to run all impacting jobs in dry run or preview mode. + type: boolean + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + run-workflow: + name: Run Workflow + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} + steps: + - id: skip + run: echo "Running workflow" + + version: + name: Version + runs-on: ubuntu-latest + needs: run-workflow + if: ${{ github.event_name != 'pull_request' }} + outputs: + version: ${{ steps.version.outputs.version }} + permissions: + contents: write + issues: write + pull-requests: write + id-token: none + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: true + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + semantic-release-license + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - id: version + run: | + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then + echo "version=v${SEMREL_INFO_NEXT_VERSION#v}" >> $GITHUB_OUTPUT + else + DESCRIBE=$(git describe --tags || echo "v0.0.0") + echo "version=v${DESCRIBE#v}" >> $GITHUB_OUTPUT + fi + env: + SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} + - run: echo ${VERSION} + env: + VERSION: ${{ steps.version.outputs.version }} + + hugo-build: + name: Hugo Build + runs-on: ubuntu-latest + needs: version + steps: + - uses: actions/checkout@v4 + with: + submodules: true # fetch Hugo themes (true OR recursive) + fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod + - uses: actions/cache@v4 + with: + path: /home/runner/.cache/hugo_cache + key: hugo-${{ hashFiles('go.sum') }} + restore-keys: | + hugo- + # https://github.com/marketplace/actions/hugo-setup + - uses: peaceiris/actions-hugo@v3 + with: + hugo-version: latest + extended: true + - run: hugo --gc --minify --destination dist + env: + VERSION: ${{ needs.version.outputs.version }} + - uses: actions/upload-pages-artifact@v3 + with: + name: github-pages + path: dist + retention-days: 1 + + pages: + name: Pages + runs-on: ubuntu-latest + needs: + - hugo-build + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + id-token: write + pages: write + pull-request: write + steps: + - id: deployment + uses: actions/deploy-pages@v4 + with: + artifact_name: github-pages + preview: ${{ inputs.dry_run == 'true' || (github.event_name != 'workflow_dispatch' && github.ref_name != github.event.repository.default_branch) }} + + release: + name: Release + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref_protected == 'true' }} + environment: + name: release + url: ${{ github.server_url }}/${{ github.repository_owner }}/${{ github.repository }}/releases/tag/${{ steps.semrel_version.outputs.new_release_version }} + needs: + - hugo-build + - pages + permissions: + contents: write + issues: write + pull-requests: write + id-token: none + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: ${{ inputs.dry_run == 'true' }} + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + semantic-release-license + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.github/workflows/dependencies.yml b/examples/hugo_github/.github/workflows/dependencies.yml similarity index 99% rename from testdata/golang/success_binary_all_github/.github/workflows/dependencies.yml rename to examples/hugo_github/.github/workflows/dependencies.yml index 8bc2167f..e1c14270 100644 --- a/testdata/golang/success_binary_all_github/.github/workflows/dependencies.yml +++ b/examples/hugo_github/.github/workflows/dependencies.yml @@ -19,7 +19,6 @@ on: - v[0-9]+.x jobs: - go-dependency-submission: name: Go Dependency Submission runs-on: ubuntu-latest diff --git a/examples/hugo_github/.github/workflows/hugo.yml b/examples/hugo_github/.github/workflows/hugo.yml index 318e763f..ffc1e95f 100644 --- a/examples/hugo_github/.github/workflows/hugo.yml +++ b/examples/hugo_github/.github/workflows/hugo.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/cache@v4 with: path: /home/runner/.cache/hugo_cache - key: hugo-${{ hashFiles('**/go.sum') }} + key: hugo-${{ hashFiles('go.sum') }} restore-keys: | hugo- # https://github.com/marketplace/actions/hugo-setup @@ -32,9 +32,4 @@ jobs: with: name: github-pages path: dist - retention-days: 1 - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist retention-days: 1 \ No newline at end of file diff --git a/examples/hugo_github/.github/workflows/labeler.yml b/examples/hugo_github/.github/workflows/labeler.yml index a729aada..8267a228 100644 --- a/examples/hugo_github/.github/workflows/labeler.yml +++ b/examples/hugo_github/.github/workflows/labeler.yml @@ -9,17 +9,13 @@ on: - opened - reopened - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize + - ready_for_review jobs: - labeler: name: Labeler runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected == false) }} permissions: contents: read # enfore rights to specify no release, even draft, is created pull-requests: write diff --git a/examples/hugo_github/.github/workflows/pages.yml b/examples/hugo_github/.github/workflows/pages.yml deleted file mode 100644 index 19fce363..00000000 --- a/examples/hugo_github/.github/workflows/pages.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Pages -run-name: Pages - -on: - workflow_call: - workflow_dispatch: - -jobs: - - hugo: - name: Hugo - uses: ./.github/workflows/hugo.yml - - pages: - name: Pages - runs-on: ubuntu-latest - needs: - - hugo - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - permissions: - pages: write - id-token: write - steps: - - id: deployment - uses: actions/deploy-pages@v4 - with: - artifact_name: github-pages - preview: ${{ github.ref_name != github.event.repository.default_branch }} \ No newline at end of file diff --git a/examples/hugo_github/.github/workflows/release.yml b/examples/hugo_github/.github/workflows/release.yml deleted file mode 100644 index bcf99f89..00000000 --- a/examples/hugo_github/.github/workflows/release.yml +++ /dev/null @@ -1,73 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - permissions: - contents: write - issues: write - pull-requests: write - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - uses: actions/checkout@v4 - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - pages: - name: Pages - uses: ./.github/workflows/pages.yml - permissions: - pages: write - id-token: write - - release: - name: Release - runs-on: ubuntu-latest - environment: release - permissions: - contents: write - issues: write - pull-requests: write - needs: - - version - - pages - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/examples/hugo_github/.github/workflows/renovate.yml b/examples/hugo_github/.github/workflows/renovate.yml index ac0b83b4..4a90a1b4 100644 --- a/examples/hugo_github/.github/workflows/renovate.yml +++ b/examples/hugo_github/.github/workflows/renovate.yml @@ -7,14 +7,13 @@ on: workflow_dispatch: inputs: dry_run: - description: Dry run + description: Whether to only run renovate job in dry run mode or let renovate create pull requests. type: boolean default: false schedule: - cron: "0 12 * * *" jobs: - renovate: name: Renovate runs-on: ubuntu-latest diff --git a/examples/hugo_github/.releaserc.yml b/examples/hugo_github/.releaserc.yml index d5afe7b3..c4cea632 100644 --- a/examples/hugo_github/.releaserc.yml +++ b/examples/hugo_github/.releaserc.yml @@ -88,5 +88,4 @@ plugins: successCommentCondition: <% return true; %> assets: - label: CHANGELOG.md - path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file + path: CHANGELOG.md \ No newline at end of file diff --git a/examples/hugo_github/renovate.json5 b/examples/hugo_github/renovate.json5 index c72eaaf5..a6b59c8d 100644 --- a/examples/hugo_github/renovate.json5 +++ b/examples/hugo_github/renovate.json5 @@ -107,18 +107,6 @@ "matchCategories": [ "ci" ], "matchUpdateTypes": [ "major" ] }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, { "addLabels": [ "non-major" ], "groupName": "golang dependencies (non major)", @@ -131,77 +119,5 @@ "matchCategories": [ "golang" ], "matchUpdateTypes": [ "major" ] }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "js dependencies (non major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "js dependencies (major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "major" ] - }, ], } \ No newline at end of file diff --git a/examples/hugo_gitlab/.gitlab-ci.yml b/examples/hugo_gitlab/.gitlab-ci.yml index 37bcd914..2972d984 100644 --- a/examples/hugo_gitlab/.gitlab-ci.yml +++ b/examples/hugo_gitlab/.gitlab-ci.yml @@ -1,5 +1,4 @@ # Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. --- include: .gitlab/workflows/.gitlab-ci.yml diff --git a/examples/hugo_gitlab/.gitlab/workflows/.gitlab-ci.yml b/examples/hugo_gitlab/.gitlab/workflows/.gitlab-ci.yml index da54559b..0cccb997 100644 --- a/examples/hugo_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ b/examples/hugo_gitlab/.gitlab/workflows/.gitlab-ci.yml @@ -21,39 +21,28 @@ variables: SEMREL_AUTO_RELEASE_ENABLED: "false" semantic-release-info: + variables: + GIT_DEPTH: "0" after_script: - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then + echo "BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8)" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi + else + DESCRIBE=$(git describe --tags || echo "v1.0.0") + echo "SEMREL_INFO_NEXT_VERSION=v${DESCRIBE#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" +semantic-release: + variables: + GIT_DEPTH: "0" + hugo-build: image: registry.gitlab.com/pages/hugo/hugo_extended:latest stage: build diff --git a/examples/hugo_gitlab/.releaserc.yml b/examples/hugo_gitlab/.releaserc.yml index 5db47095..ec3ce8d8 100644 --- a/examples/hugo_gitlab/.releaserc.yml +++ b/examples/hugo_gitlab/.releaserc.yml @@ -87,5 +87,4 @@ plugins: successCommentCondition: <% return true; %> assets: - label: CHANGELOG.md - path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file + path: CHANGELOG.md \ No newline at end of file diff --git a/examples/nodejs_github/.github/actions/docker/action.yml b/examples/nodejs_github/.github/actions/docker/action.yml new file mode 100644 index 00000000..18f74f8e --- /dev/null +++ b/examples/nodejs_github/.github/actions/docker/action.yml @@ -0,0 +1,115 @@ +# Code generated by craft; DO NOT EDIT. + +name: Docker +description: Run hadolint on Dockerfile, build the docker image, deploys it and then run trivy security analysis on it + +inputs: + registry: + default: "" + description: Docker registry on which push the docker image. By default it will be Docker Hub. + image: + description: Full docker image name (without registry). By default it will be github.repository value. + version: + description: Docker image version. + required: true + registry_token: + description: Docker registry access token. + required: true + +runs: + using: composite + steps: + - uses: actions/checkout@v4 + + ######################################################## + # Hadolint + ######################################################## + + - uses: hadolint/hadolint-action@v3.1.0 + with: + format: sarif + output-file: hadolint-results.sarif + - if: ${{ ! cancelled() }} + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: hadolint-results.sarif + category: docker-hadolint + - id: hadolint + if: ${{ ! cancelled() }} + uses: hadolint/hadolint-action@v3.1.0 + with: + format: tty + + ######################################################## + # Build + ######################################################## + + - id: image + shell: bash + run: | + : "${DOCKER_IMAGE:=${GITHUB_REPOSIORY}}" + image="$([ "${DOCKER_REGISTRY}" != "" ] && echo "${DOCKER_REGISTRY}/${DOCKER_IMAGE}" || echo "${DOCKER_IMAGE}")" + echo "Building docker image with full name '${image}'" + echo "image=${image}" >> $GITHUB_OUTPUT + env: + DOCKER_IMAGE: ${{ inputs.image }} + DOCKER_REGISTRY: ${{ inputs.registry }} + # https://github.com/marketplace/actions/docker-metadata-action + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image.outputs.image }} + labels: | + org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} + org.opencontainers.image.ref.name=${{ github.ref_name }} + org.opencontainers.image.version=${{ inputs.version }} + org.opencontainers.image.revision=${{ github.sha }} + tags: | + type=raw,enable={{is_default_branch}},value=latest + type=semver,enable=true,pattern={{raw}},value=${{ inputs.version }} + type=semver,enable=${{ github.ref_type == 'tag' }},pattern=v{{major}}.{{minor}},value=${{ inputs.version }} + type=semver,enable=${{ github.ref_type == 'tag' }},pattern=v{{major}},value=${{ inputs.version }} + # https://github.com/marketplace/actions/docker-setup-buildx + - uses: docker/setup-buildx-action@v3 + # https://github.com/marketplace/actions/docker-login + - uses: docker/login-action@v3 + with: + registry: ${{ inputs.registry }} + username: ${{ github.repository_owner }} + password: ${{ inputs.registry_token }} + # https://github.com/marketplace/actions/build-and-push-docker-images + - uses: docker/build-push-action@v6 + with: + context: . + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + + ######################################################## + # Trivy + ######################################################## + + - uses: aquasecurity/trivy-action@master + with: + format: sarif + ignore-unfixed: false + image-ref: ${{ steps.image.outputs.image }}:${{ inputs.version }} + output: trivy-results.sarif + severity: MEDIUM,HIGH,CRITICAL + env: + TRIVY_USERNAME: ${{ github.repository_owner }} + TRIVY_PASSWORD: ${{ inputs.registry_token }} + - uses: github/codeql-action/upload-sarif@v3 + with: + category: docker-trivy + sarif_file: trivy-results.sarif + - uses: aquasecurity/trivy-action@master + with: + exit-code: "1" + ignore-unfixed: false + image-ref: ${{ steps.image.outputs.image }}:${{ inputs.version }} + severity: MEDIUM,HIGH,CRITICAL + env: + TRIVY_USERNAME: ${{ github.repository_owner }} + TRIVY_PASSWORD: ${{ inputs.registry_token }} \ No newline at end of file diff --git a/examples/nodejs_github/.github/actions/version/action.yml b/examples/nodejs_github/.github/actions/version/action.yml deleted file mode 100644 index 78b981f2..00000000 --- a/examples/nodejs_github/.github/actions/version/action.yml +++ /dev/null @@ -1,106 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - npm_token: - description: Access token for the npm registry - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - - if: ${{ inputs.download_dist == 'true' }} - uses: actions/download-artifact@v4 - with: - name: build - path: dist - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/npm - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - semantic-release-license - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - NPM_TOKEN: ${{ inputs.npm_token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/examples/nodejs_github/.github/workflows/ci.yml b/examples/nodejs_github/.github/workflows/ci.yml new file mode 100644 index 00000000..7f6d5dd0 --- /dev/null +++ b/examples/nodejs_github/.github/workflows/ci.yml @@ -0,0 +1,351 @@ +# Code generated by craft; DO NOT EDIT. + +name: CICD +run-name: CICD + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + push: + branches: + - alpha + - beta + - dev + - develop + - development + - next + - staging + - main + - master + - v[0-9]+.x + - v[0-9]+.[0-9]+.x + workflow_dispatch: + inputs: + dry_run: + description: Whether to run all impacting jobs in dry run or preview mode. + type: boolean + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + run-workflow: + name: Run Workflow + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} + steps: + - id: skip + run: echo "Running workflow" + + version: + name: Version + runs-on: ubuntu-latest + needs: run-workflow + if: ${{ github.event_name != 'pull_request' }} + outputs: + version: ${{ steps.version.outputs.version }} + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: true + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + @semantic-release/npm + semantic-release-license + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - id: version + run: | + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then + echo "version=v${SEMREL_INFO_NEXT_VERSION#v}" >> $GITHUB_OUTPUT + else + DESCRIBE=$(git describe --tags || echo "v0.0.0") + echo "version=v${DESCRIBE#v}" >> $GITHUB_OUTPUT + fi + env: + SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} + - run: echo ${VERSION} + env: + VERSION: ${{ steps.version.outputs.version }} + + node-audit: + name: Node Audit + runs-on: ubuntu-latest + needs: run-workflow + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + cache: pnpm + node-version: lts/* + - run: pnpm audit + + node-lint: + name: Node Lint + runs-on: ubuntu-latest + needs: run-workflow + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + cache: pnpm + node-version: lts/* + - run: mkdir -p reports/ + - run: pnpm install --frozen-lockfile + - run: pnpm run lint -o reports/node-lint.xslint.json -f json + - uses: actions/upload-artifact@v4 + with: + name: lint + path: reports + retention-days: 1 + + node-test: + name: Node Test + runs-on: ${{ matrix.os }} + needs: run-workflow + strategy: + fail-fast: false + matrix: + os: + - macos-latest + - ubuntu-latest + - windows-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + cache: pnpm + node-version: lts/* + - run: mkdir -p reports/ + - run: pnpm install-test --frozen-lockfile + - uses: codecov/codecov-action@v4 + with: + codecov_yml_path: .codecov.yml + disable_search: true + env_vars: OS + fail_ci_if_error: false + files: reports/lcov.info + slug: ${{ github.repository }} + token: ${{ secrets.CODECOV_TOKEN }} + env: + OS: ${{ matrix.os }} + - uses: actions/upload-artifact@v4 + with: + name: coverage + path: reports + retention-days: 1 + + node-build: + name: Node Build + runs-on: ubuntu-latest + needs: + - version + - node-test + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + cache: pnpm + node-version: lts/* + - run: pnpm install --frozen-lockfile + - run: pnpm run build + env: + VERSION: ${{ needs.version.outputs.version }} + - uses: actions/upload-artifact@v4 + with: + name: build + path: dist + retention-days: 1 + + sonar-analysis: + name: Sonar Analysis + runs-on: ubuntu-latest + needs: + - node-lint + - node-test + env: + SONAR_USER_HOME: .sonar + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: reports + - uses: actions/cache@v4 + with: + path: ${{ env.SONAR_USER_HOME }} + key: sonar-cache + - if: ${{ github.event_name == 'pull_request' }} + uses: sonarsource/sonarcloud-github-action@master + with: + args: | + -Dproject.settings=sonar.properties + -Dsonar.pullrequest.base=${{ github.base_ref }} + -Dsonar.pullrequest.branch=${{ github.head_ref }} + -Dsonar.pullrequest.key=${{ github.event.issue.number }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - if: ${{ github.event_name == 'push' }} + uses: sonarsource/sonarcloud-github-action@master + with: + args: | + -Dproject.settings=sonar.properties + -Dsonar.branch.name=${{ github.ref_name }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + docker-hadolint: + name: Docker Hadolint + runs-on: ubuntu-latest + needs: run-workflow + permissions: + pull-requests: write + security-events: write + steps: + - uses: actions/checkout@v4 + - uses: hadolint/hadolint-action@v3.1.0 + continue-on-error: true # ensure sarif and tty formats are run for CodeQL and logs observability + with: + format: sarif + output-file: hadolint-results.sarif + - uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: hadolint-results.sarif + category: docker-hadolint + + docker-build: + name: Docker Build + runs-on: ubuntu-latest + needs: + - version + - node-test + environment: + name: docker + url: ${{ steps.image.outputs.full_image }} + permissions: + packages: write + security-events: write + steps: + - uses: actions/checkout@v4 + - id: image + run: | + image="$([ "${DOCKER_REGISTRY}" != "" ] && echo "${DOCKER_REGISTRY}/${GITHUB_REPOSIORY}" || echo "${GITHUB_REPOSIORY}")" + echo "Building docker image with full name '${image}'" + echo "image=${image}" >> $GITHUB_OUTPUT + + echo "full_image=${image}:${IMAGE_VERSION}" >> $GITHUB_OUTPUT + if [[ "${IMAGE_VERSION#v}" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then + echo "stable=true" >> $GITHUB_OUTPUT + fi + env: + DOCKER_REGISTRY: ghcr.io + IMAGE_VERSION: ${{ needs.version.outputs.version }} + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image.outputs.image }} + labels: | + org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} + org.opencontainers.image.ref.name=${{ github.ref_name }} + org.opencontainers.image.version=${{ needs.version.outputs.version }} + org.opencontainers.image.revision=${{ github.sha }} + tags: | + type=raw,enable={{is_default_branch}},value=latest + type=semver,enable=true,pattern={{raw}},value=${{ needs.version.outputs.version }} + type=semver,enable=${{ steps.image.outputs.stable == 'true' }},pattern=v{{major}}.{{minor}},value=${{ needs.version.outputs.version }} + type=semver,enable=${{ steps.image.outputs.stable == 'true' }},pattern=v{{major}},value=${{ needs.version.outputs.version }} + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v6 + with: + context: . + labels: ${{ steps.meta.outputs.labels }} + push: true + tags: ${{ steps.meta.outputs.tags }} + - uses: aquasecurity/trivy-action@master + with: + exit-code: 0 + format: sarif + ignore-unfixed: false + image-ref: ${{ steps.image.outputs.full_image }} + output: trivy-results.sarif + severity: MEDIUM,HIGH,CRITICAL + env: + TRIVY_USERNAME: ${{ github.repository_owner }} + TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + - uses: github/codeql-action/upload-sarif@v3 + with: + category: docker-trivy + sarif_file: trivy-results.sarif + + release: + name: Release + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref_protected == 'true' }} + environment: + name: release + url: ${{ github.server_url }}/${{ github.repository_owner }}/${{ github.repository }}/releases/tag/${{ steps.semrel_version.outputs.new_release_version }} + needs: + - node-build + - docker-build + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + - uses: actions/download-artifact@v4 + with: + name: build + path: dist + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: ${{ inputs.dry_run == 'true' }} + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits + @semantic-release/npm + semantic-release-license + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/examples/nodejs_github/.github/workflows/codeql.yml b/examples/nodejs_github/.github/workflows/codeql.yml index d6a8aac2..ef58ac2c 100644 --- a/examples/nodejs_github/.github/workflows/codeql.yml +++ b/examples/nodejs_github/.github/workflows/codeql.yml @@ -10,7 +10,7 @@ # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. -# + name: CodeQL run-name: CodeQL diff --git a/testdata/golang/success_releases_github/.github/workflows/dependencies.yml b/examples/nodejs_github/.github/workflows/dependencies.yml similarity index 99% rename from testdata/golang/success_releases_github/.github/workflows/dependencies.yml rename to examples/nodejs_github/.github/workflows/dependencies.yml index 8bc2167f..e1c14270 100644 --- a/testdata/golang/success_releases_github/.github/workflows/dependencies.yml +++ b/examples/nodejs_github/.github/workflows/dependencies.yml @@ -19,7 +19,6 @@ on: - v[0-9]+.x jobs: - go-dependency-submission: name: Go Dependency Submission runs-on: ubuntu-latest diff --git a/examples/nodejs_github/.github/workflows/docker.yml b/examples/nodejs_github/.github/workflows/docker.yml deleted file mode 100644 index e27d7645..00000000 --- a/examples/nodejs_github/.github/workflows/docker.yml +++ /dev/null @@ -1,179 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Docker -run-name: Docker - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - workflow_call: - inputs: - release: - description: Whether the docker built image must be propagated to major and minor tags or not - required: false - type: boolean - version: - description: The docker tag to build - required: false - type: string - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - version: - name: Version - runs-on: ubuntu-latest - environment: release - needs: run-workflow - if: ${{ github.event_name != 'pull_request' }} - permissions: - contents: write - issues: write - pull-requests: write - id-token: write - outputs: - release: ${{ steps.version_merge.outputs.release }} - version: ${{ steps.version_merge.outputs.version }} - steps: - - uses: actions/checkout@v4 - - id: version - if: ${{ github.event_name == 'workflow_dispatch' }} - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} - npm_token: ${{ secrets.NPM_TOKEN }} - - id: version_merge - run: | - if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then - echo "release=${RELEASE}" >> $GITHUB_OUTPUT - echo "version=${VERSION}" >> $GITHUB_OUTPUT - exit 0 - fi - echo "release=${INPUTS_RELEASE}" >> $GITHUB_OUTPUT - echo "version=${INPUTS_VERSION}" >> $GITHUB_OUTPUT - env: - VERSION: ${{ steps.version.outputs.version }} - RELEASE: ${{ steps.version.outputs.release }} - INPUTS_VERSION: ${{ inputs.version }} - INPUTS_RELEASE: ${{ inputs.release }} - - docker-hadolint: - name: Docker Hadolint - runs-on: ubuntu-latest - needs: run-workflow - permissions: - pull-requests: write - security-events: write - steps: - - uses: actions/checkout@v4 - - uses: hadolint/hadolint-action@v3.1.0 - with: - format: sarif - output-file: hadolint-results.sarif - - if: ${{ ! cancelled() }} - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: hadolint-results.sarif - category: docker-hadolint - - id: hadolint - if: ${{ ! cancelled() }} - uses: hadolint/hadolint-action@v3.1.0 - with: - format: tty - - docker-build: - name: Docker Build - runs-on: ubuntu-latest - environment: docker - needs: - - run-workflow - - version - outputs: - image: ${{ steps.image.outputs.image }} - steps: - - uses: actions/checkout@v4 - - id: image - run: | - IMAGE="ghcr.io/$GITHUB_REPOSITORY" - if [ "$RELEASE" != "true" ]; then - IMAGE="$IMAGE/snapshot" - fi - echo "image=$IMAGE" >> $GITHUB_OUTPUT - env: - RELEASE: ${{ needs.version.outputs.release }} - - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ steps.image.outputs.image }} - labels: | - org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} - org.opencontainers.image.ref.name="${{ github.ref_name }}" - org.opencontainers.image.version="${{ needs.version.outputs.version }}" - org.opencontainers.image.revision="${{ github.sha }}" - tags: | - type=raw,enable={{is_default_branch}},value=latest - type=semver,enable=true,pattern={{raw}},value=${{ needs.version.outputs.version }} - type=semver,enable=${{ needs.version.outputs.release }},pattern=v{{major}}.{{minor}},value=${{ needs.version.outputs.version }} - type=semver,enable=${{ needs.version.outputs.release }},pattern=v{{major}},value=${{ needs.version.outputs.version }} - - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.REGISTRY_TOKEN }} - - uses: docker/build-push-action@v6 - with: - context: . - labels: ${{ steps.meta.outputs.labels }} - push: true - tags: ${{ steps.meta.outputs.tags }} - - docker-trivy: - name: Docker Trivy - runs-on: ubuntu-latest - environment: docker - permissions: - security-events: write - needs: - - run-workflow - - version - - docker-build - steps: - - uses: aquasecurity/trivy-action@master - with: - format: sarif - ignore-unfixed: false - image-ref: "${{ needs.docker-build.outputs.image }}:${{ needs.version.outputs.version }}" - output: trivy-results.sarif - severity: MEDIUM,HIGH,CRITICAL - env: - TRIVY_USERNAME: ${{ github.repository_owner }} - TRIVY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} - - uses: github/codeql-action/upload-sarif@v3 - with: - category: docker-trivy - sarif_file: trivy-results.sarif - - uses: aquasecurity/trivy-action@master - with: - exit-code: "1" - ignore-unfixed: false - image-ref: "${{ needs.docker-build.outputs.image }}:${{ needs.version.outputs.version }}" - severity: MEDIUM,HIGH,CRITICAL - env: - TRIVY_USERNAME: ${{ github.repository_owner }} - TRIVY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} \ No newline at end of file diff --git a/examples/nodejs_github/.github/workflows/labeler.yml b/examples/nodejs_github/.github/workflows/labeler.yml index a729aada..8267a228 100644 --- a/examples/nodejs_github/.github/workflows/labeler.yml +++ b/examples/nodejs_github/.github/workflows/labeler.yml @@ -9,17 +9,13 @@ on: - opened - reopened - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize + - ready_for_review jobs: - labeler: name: Labeler runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected == false) }} permissions: contents: read # enfore rights to specify no release, even draft, is created pull-requests: write diff --git a/examples/nodejs_github/.github/workflows/nodejs.yml b/examples/nodejs_github/.github/workflows/nodejs.yml index 26d15fe2..4f62dff3 100644 --- a/examples/nodejs_github/.github/workflows/nodejs.yml +++ b/examples/nodejs_github/.github/workflows/nodejs.yml @@ -4,49 +4,18 @@ name: Node run-name: Node on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x workflow_call: inputs: - build: - description: Whether to run build job or not - required: false - type: boolean - workflow_dispatch: + event_name: + description: GitHub Actions real event_name since it will always 'workflow_dispatch' by default. + required: true + type: string jobs: - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - node-audit: name: Node Audit runs-on: ubuntu-latest - needs: run-workflow steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 @@ -59,7 +28,6 @@ jobs: node-lint: name: Node Lint runs-on: ubuntu-latest - needs: run-workflow steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 @@ -79,7 +47,6 @@ jobs: node-test: name: Node Test runs-on: ${{ matrix.os }} - needs: run-workflow strategy: fail-fast: false matrix: @@ -98,8 +65,7 @@ jobs: node-version: lts/* - run: mkdir -p reports/ - run: pnpm install-test --frozen-lockfile - - if: ${{ ! startsWith(github.head_ref, 'dependabot') && ! startsWith(github.head_ref, 'renovate') }} - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v4 with: codecov_yml_path: .codecov.yml disable_search: true @@ -117,9 +83,7 @@ jobs: node-build: name: Node Build runs-on: ubuntu-latest - if: ${{ inputs.build }} needs: - - run-workflow - node-test steps: - uses: actions/checkout@v4 @@ -140,7 +104,6 @@ jobs: name: Sonar Analysis runs-on: ubuntu-latest needs: - - run-workflow - node-lint - node-test env: @@ -154,24 +117,24 @@ jobs: with: path: ${{ env.SONAR_USER_HOME }} key: sonar-cache - - if: ${{ github.event_name == 'pull_request' }} + - if: ${{ inputs.event_name == 'pull_request' }} uses: sonarsource/sonarcloud-github-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: args: | -Dproject.settings=sonar.properties -Dsonar.pullrequest.base=${{ github.base_ref }} -Dsonar.pullrequest.branch=${{ github.head_ref }} -Dsonar.pullrequest.key=${{ github.event.issue.number }} - - if: ${{ github.event_name == 'push' }} - uses: sonarsource/sonarcloud-github-action@master env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - if: ${{ inputs.event_name == 'push' }} + uses: sonarsource/sonarcloud-github-action@master with: args: | -Dproject.settings=sonar.properties -Dsonar.branch.name=${{ github.ref_name }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - uses: actions/cache/save@v4 with: path: ${{ env.SONAR_USER_HOME }} diff --git a/examples/nodejs_github/.github/workflows/release.yml b/examples/nodejs_github/.github/workflows/release.yml deleted file mode 100644 index ae6f15ae..00000000 --- a/examples/nodejs_github/.github/workflows/release.yml +++ /dev/null @@ -1,91 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - permissions: - id-token: write - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.RELEASE_TOKEN }} - npm_token: ${{ secrets.NPM_TOKEN }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - node: - name: Node - uses: ./.github/workflows/nodejs.yml - with: - build: true - secrets: inherit - - docker: - name: Docker - needs: version - uses: ./.github/workflows/docker.yml - permissions: - contents: write - issues: write - pull-requests: write - id-token: write - security-events: write - with: - version: ${{ needs.version.outputs.version }} - release: ${{ needs.version.outputs.release == 'true' }} - secrets: inherit - - release: - name: Release - runs-on: ubuntu-latest - environment: release - permissions: - id-token: write - needs: - - version - - node - - docker - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ secrets.RELEASE_TOKEN }} - npm_token: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/examples/nodejs_github/.github/workflows/renovate.yml b/examples/nodejs_github/.github/workflows/renovate.yml index 149c838c..c5aada25 100644 --- a/examples/nodejs_github/.github/workflows/renovate.yml +++ b/examples/nodejs_github/.github/workflows/renovate.yml @@ -7,14 +7,13 @@ on: workflow_dispatch: inputs: dry_run: - description: Dry run + description: Whether to only run renovate job in dry run mode or let renovate create pull requests. type: boolean default: false schedule: - cron: "0 12 * * *" jobs: - renovate: name: Renovate runs-on: ubuntu-latest diff --git a/examples/nodejs_github/.releaserc.yml b/examples/nodejs_github/.releaserc.yml index 824bcf00..84304211 100644 --- a/examples/nodejs_github/.releaserc.yml +++ b/examples/nodejs_github/.releaserc.yml @@ -91,4 +91,4 @@ plugins: assets: - label: CHANGELOG.md path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file + - path: dist \ No newline at end of file diff --git a/examples/nodejs_github/Dockerfile b/examples/nodejs_github/Dockerfile new file mode 100644 index 00000000..036260d8 --- /dev/null +++ b/examples/nodejs_github/Dockerfile @@ -0,0 +1 @@ +# Code generated by craft; DO NOT EDIT. \ No newline at end of file diff --git a/examples/nodejs_github/renovate.json5 b/examples/nodejs_github/renovate.json5 index c72eaaf5..dfb71e1e 100644 --- a/examples/nodejs_github/renovate.json5 +++ b/examples/nodejs_github/renovate.json5 @@ -107,54 +107,6 @@ "matchCategories": [ "ci" ], "matchUpdateTypes": [ "major" ] }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "golang dependencies (non major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "golang dependencies (major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, { "addLabels": [ "non-major" ], "groupName": "js dependencies (non major)", @@ -169,38 +121,14 @@ }, { "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], + "groupName": "docker dependencies (non major)", + "matchCategories": [ "docker" ], "matchUpdateTypes": [ "!major" ] }, { "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], + "groupName": "docker dependencies (major)", + "matchCategories": [ "docker" ], "matchUpdateTypes": [ "major" ] }, ], diff --git a/examples/nodejs_gitlab/.gitlab-ci.yml b/examples/nodejs_gitlab/.gitlab-ci.yml index bd9b94a6..c6376f09 100644 --- a/examples/nodejs_gitlab/.gitlab-ci.yml +++ b/examples/nodejs_gitlab/.gitlab-ci.yml @@ -1,5 +1,4 @@ # Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. --- include: .gitlab/workflows/.gitlab-ci.yml diff --git a/examples/nodejs_gitlab/.gitlab/workflows/.gitlab-ci.yml b/examples/nodejs_gitlab/.gitlab/workflows/.gitlab-ci.yml index 0c2b65fd..11d94d87 100644 --- a/examples/nodejs_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ b/examples/nodejs_gitlab/.gitlab/workflows/.gitlab-ci.yml @@ -81,39 +81,28 @@ variables: SEMREL_AUTO_RELEASE_ENABLED: "false" semantic-release-info: + variables: + GIT_DEPTH: "0" after_script: - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then + echo "BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8)" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi + else + DESCRIBE=$(git describe --tags || echo "v1.0.0") + echo "SEMREL_INFO_NEXT_VERSION=v${DESCRIBE#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" +semantic-release: + variables: + GIT_DEPTH: "0" + .renovate-rules: &renovate-rules rules: # see https://gitlab.com/to-be-continuous/renovate/-/blob/master/templates/gitlab-ci-renovate.yml?ref_type=heads#L348 @@ -145,7 +134,7 @@ netlify: ENV: production when: manual - variables: - ARGS: "--alias $BRANCH_SHA" # sha is coming from version.yml file with export from semantic-release-info job + ARGS: "--alias $BRANCH_SHA" ENV: $CI_COMMIT_REF_NAME when: manual before_script: diff --git a/examples/nodejs_gitlab/.releaserc.yml b/examples/nodejs_gitlab/.releaserc.yml index e82fc70b..d4457fe4 100644 --- a/examples/nodejs_gitlab/.releaserc.yml +++ b/examples/nodejs_gitlab/.releaserc.yml @@ -90,4 +90,4 @@ plugins: assets: - label: CHANGELOG.md path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file + - path: dist \ No newline at end of file diff --git a/examples/nodejs_gitlab/Dockerfile b/examples/nodejs_gitlab/Dockerfile new file mode 100644 index 00000000..036260d8 --- /dev/null +++ b/examples/nodejs_gitlab/Dockerfile @@ -0,0 +1 @@ +# Code generated by craft; DO NOT EDIT. \ No newline at end of file diff --git a/examples/nodejs_gitlab/renovate.json5 b/examples/nodejs_gitlab/renovate.json5 index c72eaaf5..dfb71e1e 100644 --- a/examples/nodejs_gitlab/renovate.json5 +++ b/examples/nodejs_gitlab/renovate.json5 @@ -107,54 +107,6 @@ "matchCategories": [ "ci" ], "matchUpdateTypes": [ "major" ] }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "golang dependencies (non major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "golang dependencies (major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, { "addLabels": [ "non-major" ], "groupName": "js dependencies (non major)", @@ -169,38 +121,14 @@ }, { "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], + "groupName": "docker dependencies (non major)", + "matchCategories": [ "docker" ], "matchUpdateTypes": [ "!major" ] }, { "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], + "groupName": "docker dependencies (major)", + "matchCategories": [ "docker" ], "matchUpdateTypes": [ "major" ] }, ], diff --git a/internal/cobra/generate.go b/internal/cobra/generate.go index 89238e13..96a41975 100644 --- a/internal/cobra/generate.go +++ b/internal/cobra/generate.go @@ -12,58 +12,42 @@ import ( "github.com/kilianpaquier/craft/pkg/initialize" ) -var ( - force []string - forceAll bool - - generateCmd = &cobra.Command{ - Use: "generate", - Short: "Generate the project layout", - Run: func(cmd *cobra.Command, _ []string) { - ctx := cmd.Context() - destdir, _ := os.Getwd() - - config, err := initialize.Run(ctx, destdir) - if err != nil && !errors.Is(err, initialize.ErrAlreadyInitialized) { - fatal(ctx, err) - } - config.EnsureDefaults() - - // validate craft struct - if err := validator.New().Struct(config); err != nil { - fatal(ctx, err) - } - generate.SetLogger(log) - - // run generation - options := []generate.RunOption{ - generate.WithDelimiters("<<", ">>"), - generate.WithDestination(destdir), - generate.WithForce(force...), - generate.WithForceAll(forceAll), - generate.WithTemplates("templates", generate.FS()), - } - config, err = generate.Run(ctx, config, options...) - if err != nil { - fatal(ctx, err) - } - - // save craft configuration - if err := craft.Write(destdir, config); err != nil { - fatal(ctx, err) - } - }, - } -) +var generateCmd = &cobra.Command{ + Use: "generate", + Short: "Generate the project layout", + Run: func(cmd *cobra.Command, _ []string) { + ctx := cmd.Context() + destdir, _ := os.Getwd() + + config, err := initialize.Run(ctx, destdir) + if err != nil && !errors.Is(err, initialize.ErrAlreadyInitialized) { + fatal(ctx, err) + } + config.EnsureDefaults() + + // validate craft struct + if err := validator.New().Struct(config); err != nil { + fatal(ctx, err) + } + generate.SetLogger(log) + + // run generation + options := []generate.RunOption{ + generate.WithDestination(destdir), + generate.WithTemplates("templates", generate.FS()), + } + config, err = generate.Run(ctx, config, options...) + if err != nil { + fatal(ctx, err) + } + + // save craft configuration + if err := craft.Write(destdir, config); err != nil { + fatal(ctx, err) + } + }, +} func init() { rootCmd.AddCommand(generateCmd) - - generateCmd.Flags().StringSliceVarP( - &force, "force", "f", []string{}, - "force regenerating a list of templates (.gitlab-ci.yml, sonar.properties, Dockerfile, etc.)") - - generateCmd.Flags().BoolVar( - &forceAll, "force-all", false, - "force regenerating all templates (.gitlab-ci.yml, sonar.properties, Dockerfile, etc.)") } diff --git a/pkg/craft/configuration_test.go b/pkg/craft/configuration_test.go deleted file mode 100644 index 73bc6245..00000000 --- a/pkg/craft/configuration_test.go +++ /dev/null @@ -1,269 +0,0 @@ -package craft_test - -import ( - "io/fs" - "os" - "path/filepath" - "testing" - - "github.com/kilianpaquier/cli-sdk/pkg/cfs" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/kilianpaquier/craft/internal/helpers" - "github.com/kilianpaquier/craft/pkg/craft" -) - -func TestReadCraft(t *testing.T) { - t.Run("error_not_found", func(t *testing.T) { - // Arrange - srcdir := t.TempDir() - invalid := filepath.Join(srcdir, "invalid") - - // Act - var config craft.Configuration - err := craft.Read(invalid, &config) - - // Assert - assert.Equal(t, fs.ErrNotExist, err) - }) - - t.Run("error_read", func(t *testing.T) { - // Arrange - srcdir := t.TempDir() - file := filepath.Join(srcdir, craft.File) - require.NoError(t, os.Mkdir(file, cfs.RwxRxRxRx)) - - // Act - var config craft.Configuration - err := craft.Read(filepath.Dir(file), &config) - - // Assert - assert.ErrorContains(t, err, "read file") - }) - - t.Run("error_unmarshal", func(t *testing.T) { - // Arrange - srcdir := t.TempDir() - err := os.WriteFile(filepath.Join(srcdir, craft.File), []byte(`{ "key":: "value" }`), cfs.RwRR) - require.NoError(t, err) - - // Act - var config craft.Configuration - err = craft.Read(srcdir, &config) - - // Assert - assert.ErrorContains(t, err, "unmarshal") - assert.ErrorContains(t, err, "did not find expected node content") - }) - - t.Run("success", func(t *testing.T) { - // Arrange - srcdir := t.TempDir() - expected := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - NoChart: true, - } - - err := craft.Write(srcdir, expected) - require.NoError(t, err) - - // Act - var actual craft.Configuration - err = craft.Read(srcdir, &actual) - - // Assert - require.NoError(t, err) - assert.Equal(t, expected, actual) - }) -} - -func TestWriteCraft(t *testing.T) { - t.Run("error_open_craft", func(t *testing.T) { - // Arrange - srcdir := t.TempDir() - file := filepath.Join(srcdir, craft.File) - require.NoError(t, os.Mkdir(file, cfs.RwxRxRxRx)) - - // Act - err := craft.Write(srcdir, craft.Configuration{}) - - // Assert - assert.ErrorContains(t, err, "write file") - }) - - t.Run("success", func(t *testing.T) { - // Arrange - tmp := t.TempDir() - expected := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - NoChart: true, - } - - // Act - err := craft.Write(tmp, expected) - require.NoError(t, err) - - // Assert - var actual craft.Configuration - err = craft.Read(tmp, &actual) - require.NoError(t, err) - assert.Equal(t, expected, actual) - }) -} - -func TestEnsureDefaults(t *testing.T) { - t.Run("success_github_dependabot_no_auth", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - Bot: helpers.ToPtr(craft.Dependabot), - CI: &craft.CI{ - Name: craft.GitHub, - Auth: craft.Auth{Maintenance: helpers.ToPtr(craft.GitHubToken)}, - }, - } - - // Act - config.EnsureDefaults() - - // Assert - assert.Nil(t, config.CI.Auth.Maintenance) - require.NotNil(t, config.Bot) - assert.Equal(t, craft.Dependabot, *config.Bot) - }) - - t.Run("success_gitlab_force_renovate", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - Bot: helpers.ToPtr(craft.Dependabot), - CI: &craft.CI{ - Auth: craft.Auth{Maintenance: helpers.ToPtr(craft.GitHubToken)}, - }, - Platform: craft.GitLab, - } - - // Act - config.EnsureDefaults() - - // Assert - assert.Nil(t, config.CI.Auth.Maintenance) - require.NotNil(t, config.Bot) - assert.Equal(t, craft.Renovate, *config.Bot) - }) - - t.Run("success_gitlab_no_labeler", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitLab, - Options: []string{craft.Labeler}, - }, - } - - // Act - config.EnsureDefaults() - - // Assert - assert.Empty(t, config.CI.Options) - }) - - t.Run("success_no_release_means_no_release_auth", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - CI: &craft.CI{ - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubApp)}, - }, - } - - // Act - config.EnsureDefaults() - - // Assert - assert.Nil(t, config.CI.Auth.Release) - }) - - t.Run("success_default_gitlab_semrel", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitLab, - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubToken)}, - Release: &craft.Release{}, - }, - } - - // Act - config.EnsureDefaults() - - // Assert - assert.Nil(t, config.CI.Auth.Release) - }) - - t.Run("success_migrate_dependabot", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitHub, - Options: []string{craft.Dependabot}, - }, - } - - // Act - config.EnsureDefaults() - - // Assert - require.NotNil(t, config.Bot) - assert.Equal(t, craft.Dependabot, *config.Bot) - }) - - t.Run("success_migrate_renovate", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitHub, - Options: []string{craft.Renovate}, - }, - } - - // Act - config.EnsureDefaults() - - // Assert - require.NotNil(t, config.Bot) - assert.Equal(t, craft.Renovate, *config.Bot) - }) - - t.Run("success_migrate_netlify", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitHub, - Options: []string{craft.Netlify}, - }, - } - - // Act - config.EnsureDefaults() - - // Assert - require.NotNil(t, config.CI.Static) - assert.Equal(t, craft.Netlify, config.CI.Static.Name) - }) - - t.Run("success_migrate_pages", func(t *testing.T) { - // Arrange - config := craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitHub, - Options: []string{craft.Pages}, - }, - } - - // Act - config.EnsureDefaults() - - // Assert - require.NotNil(t, config.CI.Static) - assert.Equal(t, craft.Pages, config.CI.Static.Name) - }) -} diff --git a/pkg/craft/constants.go b/pkg/craft/constants.go index da32bd11..7ba3bac7 100644 --- a/pkg/craft/constants.go +++ b/pkg/craft/constants.go @@ -7,6 +7,17 @@ const ( // TmplExtension is the extension for templates file. TmplExtension = ".tmpl" + // PartExtension is the extension for templates files' subparts. + // + // It must be used with TmplExtension + // and as such files with only templates parts (define) can be created. + PartExtension = ".part" + + // PatchExtension is the extension for templates files patches. + // + // It will be used in the future to patch altered files by users to follow updates with less generation issues. + PatchExtension = ".patch" + // Gocmd represents the cmd folder where go main.go should be placed according to go layout. Gocmd = "cmd" // Gomod represents the go.mod filename. diff --git a/pkg/craft/defaults.go b/pkg/craft/defaults.go index c57c7ad4..40e72898 100644 --- a/pkg/craft/defaults.go +++ b/pkg/craft/defaults.go @@ -14,7 +14,7 @@ func (c *Configuration) EnsureDefaults() { // ensure defaults values are set for maintenance bot if c.Bot != nil { if c.Platform == GitLab { - c.Bot = helpers.ToPtr(Renovate) // dependabot is not available on craft for gitlab + c.Bot = helpers.ToPtr(Renovate) // dependabot is not available on craft for GitLab } } @@ -30,12 +30,14 @@ func (c *Configuration) ensureDefaultCI() { if c.Bot != nil { if *c.Bot == Dependabot || c.Platform == GitLab { c.CI.Auth.Maintenance = nil // dependabot and gitlab don't need any mode + } else if *c.Bot == Renovate && c.CI.Auth.Maintenance == nil { + c.CI.Auth.Maintenance = helpers.ToPtr(GitHubToken) } } - // specific gitlab CICD - if c.CI.Name == GitLab { - c.CI.Options = slices.DeleteFunc(c.CI.Options, func(option string) bool { return option == Labeler }) // labeler isn't available on gitlab CICD + // labeler is only available on GitHub Actions + if c.CI.Name != GitHub { + c.CI.Options = slices.DeleteFunc(c.CI.Options, func(option string) bool { return option == Labeler }) } func() { @@ -51,40 +53,13 @@ func (c *Configuration) ensureDefaultCI() { c.CI.Auth.Release = helpers.ToPtr(GitHubToken) // set default release mode for github actions } - // specific gitlab CICD + // specific GitLab CICD if c.CI.Name == GitLab { - c.CI.Auth.Release = nil // release auth isn't available with gitlab CICD + c.CI.Auth.Release = nil // release auth isn't available with GitLab CICD } }() } -func (c *Configuration) retroCompatibility() { - if c.CI != nil { - // generic function to match an option included in a slice of options - del := func(options ...string) func(option string) bool { - return func(option string) bool { - return slices.Contains(options, option) - } - } - - // migrate old renovate / dependabot option - switch { - case slices.Contains(c.CI.Options, Dependabot): - c.Bot = helpers.ToPtr(Dependabot) - c.CI.Options = slices.DeleteFunc(c.CI.Options, del(Dependabot)) - case slices.Contains(c.CI.Options, Renovate): - c.Bot = helpers.ToPtr(Renovate) - c.CI.Options = slices.DeleteFunc(c.CI.Options, del(Renovate)) - } - - // migrate old netlify / pages option - switch { - case slices.Contains(c.CI.Options, Netlify): - c.CI.Static = &Static{Name: Netlify} - c.CI.Options = slices.DeleteFunc(c.CI.Options, del(Netlify)) - case slices.Contains(c.CI.Options, Pages): - c.CI.Static = &Static{Name: Pages} - c.CI.Options = slices.DeleteFunc(c.CI.Options, del(Pages)) - } - } +func (*Configuration) retroCompatibility() { + // TBD in case a migration is needed } diff --git a/pkg/craft/defaults_test.go b/pkg/craft/defaults_test.go new file mode 100644 index 00000000..35714534 --- /dev/null +++ b/pkg/craft/defaults_test.go @@ -0,0 +1,99 @@ +package craft_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/kilianpaquier/craft/internal/helpers" + "github.com/kilianpaquier/craft/pkg/craft" +) + +func TestEnsureDefaults(t *testing.T) { + t.Run("success_github_dependabot_no_auth", func(t *testing.T) { + // Arrange + config := craft.Configuration{ + Bot: helpers.ToPtr(craft.Dependabot), + CI: &craft.CI{ + Name: craft.GitHub, + Auth: craft.Auth{Maintenance: helpers.ToPtr(craft.GitHubToken)}, + }, + } + + // Act + config.EnsureDefaults() + + // Assert + assert.Nil(t, config.CI.Auth.Maintenance) + require.NotNil(t, config.Bot) + assert.Equal(t, craft.Dependabot, *config.Bot) + }) + + t.Run("success_gitlab_force_renovate", func(t *testing.T) { + // Arrange + config := craft.Configuration{ + Bot: helpers.ToPtr(craft.Dependabot), + CI: &craft.CI{ + Auth: craft.Auth{Maintenance: helpers.ToPtr(craft.GitHubToken)}, + }, + Platform: craft.GitLab, + } + + // Act + config.EnsureDefaults() + + // Assert + assert.Nil(t, config.CI.Auth.Maintenance) + require.NotNil(t, config.Bot) + assert.Equal(t, craft.Renovate, *config.Bot) + }) + + t.Run("success_gitlab_no_labeler", func(t *testing.T) { + // Arrange + config := craft.Configuration{ + CI: &craft.CI{ + Name: craft.GitLab, + Options: []string{craft.Labeler}, + }, + } + + // Act + config.EnsureDefaults() + + // Assert + assert.Empty(t, config.CI.Options) + }) + + t.Run("success_no_release_means_no_release_auth", func(t *testing.T) { + // Arrange + config := craft.Configuration{ + CI: &craft.CI{ + Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubApp)}, + }, + } + + // Act + config.EnsureDefaults() + + // Assert + assert.Nil(t, config.CI.Auth.Release) + }) + + t.Run("success_default_gitlab_semrel", func(t *testing.T) { + // Arrange + config := craft.Configuration{ + CI: &craft.CI{ + Name: craft.GitLab, + Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubToken)}, + Release: &craft.Release{}, + }, + } + + // Act + config.EnsureDefaults() + + // Assert + assert.Nil(t, config.CI.Auth.Release) + }) +} diff --git a/pkg/craft/read_write.go b/pkg/craft/fs.go similarity index 100% rename from pkg/craft/read_write.go rename to pkg/craft/fs.go diff --git a/pkg/craft/fs_test.go b/pkg/craft/fs_test.go new file mode 100644 index 00000000..b6132f01 --- /dev/null +++ b/pkg/craft/fs_test.go @@ -0,0 +1,112 @@ +package craft_test + +import ( + "io/fs" + "os" + "path/filepath" + "testing" + + "github.com/kilianpaquier/cli-sdk/pkg/cfs" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/kilianpaquier/craft/pkg/craft" +) + +func TestReadCraft(t *testing.T) { + t.Run("error_not_found", func(t *testing.T) { + // Arrange + srcdir := t.TempDir() + invalid := filepath.Join(srcdir, "invalid") + + // Act + var config craft.Configuration + err := craft.Read(invalid, &config) + + // Assert + assert.Equal(t, fs.ErrNotExist, err) + }) + + t.Run("error_read", func(t *testing.T) { + // Arrange + srcdir := t.TempDir() + file := filepath.Join(srcdir, craft.File) + require.NoError(t, os.Mkdir(file, cfs.RwxRxRxRx)) + + // Act + var config craft.Configuration + err := craft.Read(filepath.Dir(file), &config) + + // Assert + assert.ErrorContains(t, err, "read file") + }) + + t.Run("error_unmarshal", func(t *testing.T) { + // Arrange + srcdir := t.TempDir() + err := os.WriteFile(filepath.Join(srcdir, craft.File), []byte(`{ "key":: "value" }`), cfs.RwRR) + require.NoError(t, err) + + // Act + var config craft.Configuration + err = craft.Read(srcdir, &config) + + // Assert + assert.ErrorContains(t, err, "unmarshal") + assert.ErrorContains(t, err, "did not find expected node content") + }) + + t.Run("success", func(t *testing.T) { + // Arrange + srcdir := t.TempDir() + expected := craft.Configuration{ + Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, + NoChart: true, + } + + err := craft.Write(srcdir, expected) + require.NoError(t, err) + + // Act + var actual craft.Configuration + err = craft.Read(srcdir, &actual) + + // Assert + require.NoError(t, err) + assert.Equal(t, expected, actual) + }) +} + +func TestWriteCraft(t *testing.T) { + t.Run("error_open_craft", func(t *testing.T) { + // Arrange + srcdir := t.TempDir() + file := filepath.Join(srcdir, craft.File) + require.NoError(t, os.Mkdir(file, cfs.RwxRxRxRx)) + + // Act + err := craft.Write(srcdir, craft.Configuration{}) + + // Assert + assert.ErrorContains(t, err, "write file") + }) + + t.Run("success", func(t *testing.T) { + // Arrange + tmp := t.TempDir() + expected := craft.Configuration{ + Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, + NoChart: true, + } + + // Act + err := craft.Write(tmp, expected) + require.NoError(t, err) + + // Assert + var actual craft.Configuration + err = craft.Read(tmp, &actual) + require.NoError(t, err) + assert.Equal(t, expected, actual) + }) +} diff --git a/testdata/nodejs/success_options_github/.codecov.yml b/pkg/generate/_templates/.codecov.yml.tmpl similarity index 59% rename from testdata/nodejs/success_options_github/.codecov.yml rename to pkg/generate/_templates/.codecov.yml.tmpl index 3b26cd7e..456fc98a 100644 --- a/testdata/nodejs/success_options_github/.codecov.yml +++ b/pkg/generate/_templates/.codecov.yml.tmpl @@ -14,9 +14,19 @@ coverage: threshold: 2.5% ignore: +{{- if hasKey .Languages "golang" }} + - "cmd" + - "examples" + - "**/cobra/**" + - "**/mocks/**" + - "**/tests/**" + - "**/testutils/**" +{{- end }} +{{- if hasKey .Languages "node" }} - "dist" - "node_modules" - "**/*.spec.js" - "**/*.spec.ts" - "**/*.test.js" - - "**/*.test.ts" \ No newline at end of file + - "**/*.test.ts" +{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/.dockerignore.tmpl b/pkg/generate/_templates/.dockerignore.tmpl similarity index 51% rename from pkg/generate/templates/.dockerignore.tmpl rename to pkg/generate/_templates/.dockerignore.tmpl index 39c47cb9..abe3d666 100644 --- a/pkg/generate/templates/.dockerignore.tmpl +++ b/pkg/generate/_templates/.dockerignore.tmpl @@ -20,39 +20,38 @@ docs/ reports/ dist/ -<<- if hasKey .Languages "nodejs" >> - # vendor dependencies +{{- if hasKey .Languages "node" }} node_modules/ -<<- end >> +{{- end }} +{{- if hasKey .Languages "golang" }} +vendor/ +{{- end }} -<<- if hasKey .Languages "golang" >> +{{- if hasKey .Languages "golang" }} # binaries -<<- range $name, $config := .Clis >> -<< $name >> -<< printf "!%s/" $name >> -<<- end >> +{{- range $name, $config := .Clis }} +{{ $name }} +{{ printf "!%s/" $name }} +{{- end }} -<<- if gt (len .Crons) 0 >> +{{- if gt (len .Crons) 0 }} cron-* !cron-*/ -<<- end >> +{{- end }} -<<- if gt (len .Jobs) 0 >> +{{- if gt (len .Jobs) 0 }} job-* !job-*/ -<<- end >> +{{- end }} -<<- if gt (len .Workers) 0 >> +{{- if gt (len .Workers) 0 }} worker-* !worker-*/ -<<- end >> +{{- end }} # test files **/*_test.go **/*.test - -# vendor dependencies -vendor/ -<<- end >> \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/.github/dependabot.yml.tmpl b/pkg/generate/_templates/.github/dependabot.yml.tmpl similarity index 76% rename from pkg/generate/templates/.github/dependabot.yml.tmpl rename to pkg/generate/_templates/.github/dependabot.yml.tmpl index 025d2f44..b5808858 100644 --- a/pkg/generate/templates/.github/dependabot.yml.tmpl +++ b/pkg/generate/_templates/.github/dependabot.yml.tmpl @@ -5,11 +5,9 @@ # Please see the documentation for all configuration options: # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file -<<- $nodejs := hasKey .Languages "nodejs" >> -<<- $hugo := hasKey .Languages "hugo" >> -<<- $golang := hasKey .Languages "golang" >> - -<<- $docker := and .Docker (gt .Binaries 0) >> +{{- $node := hasKey .Languages "node" }} +{{- $hugo := hasKey .Languages "hugo" }} +{{- $golang := hasKey .Languages "golang" }} version: 2 updates: @@ -30,11 +28,12 @@ updates: include: scope prefix: ci reviewers: -<<- range $.Maintainers >> - - << .Name >> -<<- end >> +{{- range $.Maintainers }} + - {{ .Name }} +{{- end }} + +{{- if .Docker }} -<<- if $docker >> - package-ecosystem: docker directory: / schedule: @@ -50,12 +49,13 @@ updates: include: scope prefix: chore reviewers: -<<- range $.Maintainers >> - - << .Name >> -<<- end >> -<<- end >> +{{- range $.Maintainers }} + - {{ .Name }} +{{- end }} +{{- end }} + +{{- if $golang }} -<<- if $golang >> - package-ecosystem: gomod directory: / schedule: @@ -71,12 +71,13 @@ updates: include: scope prefix: chore reviewers: -<<- range $.Maintainers >> - - << .Name >> -<<- end >> -<<- end >> +{{- range $.Maintainers }} + - {{ .Name }} +{{- end }} +{{- end }} + +{{- if $node }} -<<- if $nodejs >> - package-ecosystem: npm directory: / schedule: @@ -94,7 +95,7 @@ updates: include: scope prefix: chore reviewers: -<<- range $.Maintainers >> - - << .Name >> -<<- end >> -<<- end >> \ No newline at end of file +{{- range $.Maintainers }} + - {{ .Name }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/.github/labeler.yml.tmpl b/pkg/generate/_templates/.github/labeler.yml.tmpl similarity index 84% rename from pkg/generate/templates/.github/labeler.yml.tmpl rename to pkg/generate/_templates/.github/labeler.yml.tmpl index 21f90960..c3159ae3 100644 --- a/pkg/generate/templates/.github/labeler.yml.tmpl +++ b/pkg/generate/_templates/.github/labeler.yml.tmpl @@ -57,23 +57,23 @@ autolabeler: - "**/.github/actions/**" - "**/.github/workflows/**" -<<- /* create a map of languages for an easier evolution with new languages */ ->> -<<- $languages := dict +{{- /* create a map of languages for an easier evolution with new languages */ -}} +{{- $languages := dict "go" (list "go") "javascript" (list "js" "ts") "python" (list "py") "rust" (list "rs") "shell" (list "sh" "zsh" "bash") -->> +-}} -<<- range $label, $exts := $languages >> +{{- range $label, $exts := $languages }} - - label: << $label >> + - label: {{ $label }} files: -<<- range $exts >> - - "**/*.<< . >>" -<<- end >> -<<- end >> +{{- range $exts }} + - "**/*.{{ . }}" +{{- end }} +{{- end }} - label: dependencies title: diff --git a/pkg/generate/templates/.github/release.yml.tmpl b/pkg/generate/_templates/.github/release.yml.tmpl similarity index 100% rename from pkg/generate/templates/.github/release.yml.tmpl rename to pkg/generate/_templates/.github/release.yml.tmpl diff --git a/pkg/generate/_templates/.github/workflows/ci-docker.part.tmpl b/pkg/generate/_templates/.github/workflows/ci-docker.part.tmpl new file mode 100644 index 00000000..7c9a8f9a --- /dev/null +++ b/pkg/generate/_templates/.github/workflows/ci-docker.part.tmpl @@ -0,0 +1,103 @@ +jobs: +<<- define "docker" >> + +<<- $node := hasKey .Languages "node" >> +<<- $hugo := hasKey .Languages "hugo" >> +<<- $golang := hasKey .Languages "golang" >> + +<<- $token := "REGISTRY_TOKEN" >> +<<- if eq (fromPtr .Docker.Registry) "ghcr.io" >><<- $token = "GITHUB_TOKEN" >><<- end >> + + docker-hadolint: + name: Docker Hadolint + runs-on: ubuntu-latest + needs: run-workflow + permissions: + pull-requests: write + security-events: write + steps: + - uses: actions/checkout@v4 + - uses: hadolint/hadolint-action@v3.1.0 + continue-on-error: true # ensure sarif and tty formats are run for CodeQL and logs observability + with: + format: sarif + output-file: hadolint-results.sarif + - uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: hadolint-results.sarif + category: docker-hadolint + + docker-build: + name: Docker Build + runs-on: ubuntu-latest + needs: + - version +<<- if $node >> + - node-test +<<- end >> +<<- if $golang >> + - go-test +<<- end >> + environment: + name: docker + url: ${{ steps.image.outputs.full_image }} + permissions: + packages: << if eq (fromPtr .Docker.Registry) "ghcr.io" >>write<< else >>read<< end >> + security-events: write + steps: + - uses: actions/checkout@v4 + - id: image + run: | + image="$([ "${DOCKER_REGISTRY}" != "" ] && echo "${DOCKER_REGISTRY}/${GITHUB_REPOSIORY}" || echo "${GITHUB_REPOSIORY}")" + echo "Building docker image with full name '${image}'" + echo "image=${image}" >> $GITHUB_OUTPUT + + echo "full_image=${image}:${IMAGE_VERSION}" >> $GITHUB_OUTPUT + if [[ "${IMAGE_VERSION#v}" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then + echo "stable=true" >> $GITHUB_OUTPUT + fi + env: + DOCKER_REGISTRY: << .Docker.Registry | default ("" | quote) >> + IMAGE_VERSION: ${{ needs.version.outputs.version }} + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image.outputs.image }} + labels: | + org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} + org.opencontainers.image.ref.name=${{ github.ref_name }} + org.opencontainers.image.version=${{ needs.version.outputs.version }} + org.opencontainers.image.revision=${{ github.sha }} + tags: | + type=raw,enable={{is_default_branch}},value=latest + type=semver,enable=true,pattern={{raw}},value=${{ needs.version.outputs.version }} + type=semver,enable=${{ steps.image.outputs.stable == 'true' }},pattern=v{{major}}.{{minor}},value=${{ needs.version.outputs.version }} + type=semver,enable=${{ steps.image.outputs.stable == 'true' }},pattern=v{{major}},value=${{ needs.version.outputs.version }} + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: << .Docker.Registry | default ("" | quote) >> + username: ${{ github.repository_owner }} + password: ${{ secrets.<< $token >> }} + - uses: docker/build-push-action@v6 + with: + context: . + labels: ${{ steps.meta.outputs.labels }} + push: true + tags: ${{ steps.meta.outputs.tags }} + - uses: aquasecurity/trivy-action@master + with: + exit-code: 0 + format: sarif + ignore-unfixed: false + image-ref: ${{ steps.image.outputs.full_image }} + output: trivy-results.sarif + severity: MEDIUM,HIGH,CRITICAL + env: + TRIVY_USERNAME: ${{ github.repository_owner }} + TRIVY_PASSWORD: ${{ secrets.<< $token >> }} + - uses: github/codeql-action/upload-sarif@v3 + with: + category: docker-trivy + sarif_file: trivy-results.sarif +<<- end >> \ No newline at end of file diff --git a/.github/workflows/golang.yml b/pkg/generate/_templates/.github/workflows/ci-golang.part.tmpl similarity index 64% rename from .github/workflows/golang.yml rename to pkg/generate/_templates/.github/workflows/ci-golang.part.tmpl index 1e492cd8..a6ae6440 100644 --- a/.github/workflows/golang.yml +++ b/pkg/generate/_templates/.github/workflows/ci-golang.part.tmpl @@ -1,51 +1,5 @@ -# Code generated by craft; DO NOT EDIT. - -name: Golang -run-name: Golang - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - workflow_call: - inputs: - build: - description: Whether to run build job or not - required: false - type: boolean - version: - description: Build version to use in build metadata - required: true - type: string - workflow_dispatch: - jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT +<<- define "golang" >> go-vulncheck: name: Go Vulnerability Check @@ -76,6 +30,13 @@ jobs: - uses: golangci/golangci-lint-action@v6 with: args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number +<<- if has "sonar" .CI.Options >> + - uses: actions/upload-artifact@v4 + with: + name: lint + path: reports + retention-days: 1 +<<- end >> go-test: name: Go Test @@ -88,8 +49,6 @@ jobs: - macos-latest - ubuntu-latest - windows-latest - env: - OS: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -99,8 +58,8 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - run: mkdir -p reports/ - run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - - if: ${{ ! startsWith(github.head_ref, 'dependabot') && ! startsWith(github.head_ref, 'renovate') }} - uses: codecov/codecov-action@v4 +<<- if has "codecov" .CI.Options >> + - uses: codecov/codecov-action@v4 with: codecov_yml_path: .codecov.yml disable_search: true @@ -110,13 +69,24 @@ jobs: flags: ${{ matrix.os }} slug: ${{ github.repository }} token: ${{ secrets.CODECOV_TOKEN }} + env: + OS: ${{ matrix.os }} +<<- end >> +<<- if has "sonar" .CI.Options >> + - uses: actions/upload-artifact@v4 + with: + name: coverage + path: reports + retention-days: 1 +<<- end >> + +<<- if gt .Binaries 0 >> go-build: name: Go Build runs-on: ubuntu-latest - if: ${{ inputs.build }} needs: - - run-workflow + - version - go-test steps: - uses: actions/checkout@v4 @@ -126,11 +96,12 @@ jobs: go-version-file: go.mod token: ${{ secrets.GITHUB_TOKEN }} # https://github.com/marketplace/actions/goreleaser-action - - uses: goreleaser/goreleaser-action@v6 + - if: ${{ hashFiles('.goreleaser.yml') != '' }} + uses: goreleaser/goreleaser-action@v6 with: args: release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot env: - VERSION: ${{ inputs.version }} + VERSION: ${{ needs.version.outputs.version }} - uses: actions/upload-artifact@v4 with: name: build @@ -140,4 +111,6 @@ jobs: !dist/*.json !dist/*.yaml !dist/*/ - retention-days: 1 \ No newline at end of file + retention-days: 1 +<<- end >> +<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/lang_hugo/.github/workflows/hugo.yml.tmpl b/pkg/generate/_templates/.github/workflows/ci-hugo.part.tmpl similarity index 81% rename from pkg/generate/templates/lang_hugo/.github/workflows/hugo.yml.tmpl rename to pkg/generate/_templates/.github/workflows/ci-hugo.part.tmpl index c22ec8a2..b7b3a185 100644 --- a/pkg/generate/templates/lang_hugo/.github/workflows/hugo.yml.tmpl +++ b/pkg/generate/_templates/.github/workflows/ci-hugo.part.tmpl @@ -1,16 +1,10 @@ -# Code generated by craft; DO NOT EDIT. - -name: Hugo -run-name: Hugo - -on: - workflow_call: - jobs: +<<- define "hugo" >> hugo-build: name: Hugo Build runs-on: ubuntu-latest + needs: version steps: - uses: actions/checkout@v4 with: @@ -19,7 +13,7 @@ jobs: - uses: actions/cache@v4 with: path: /home/runner/.cache/hugo_cache - key: hugo-${{ hashFiles('**/go.sum') }} + key: hugo-${{ hashFiles('go.sum') }} restore-keys: | hugo- # https://github.com/marketplace/actions/hugo-setup @@ -28,15 +22,19 @@ jobs: hugo-version: latest extended: true - run: hugo --gc --minify --destination dist + env: + VERSION: ${{ needs.version.outputs.version }} <<- if .IsStatic "pages" >> - uses: actions/upload-pages-artifact@v3 with: name: github-pages path: dist retention-days: 1 -<<- end >> +<<- else >> - uses: actions/upload-artifact@v4 with: name: build path: dist - retention-days: 1 \ No newline at end of file + retention-days: 1 +<<- end >> +<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/lang_nodejs/.github/workflows/nodejs.yml.tmpl b/pkg/generate/_templates/.github/workflows/ci-nodejs.part.tmpl similarity index 55% rename from pkg/generate/templates/lang_nodejs/.github/workflows/nodejs.yml.tmpl rename to pkg/generate/_templates/.github/workflows/ci-nodejs.part.tmpl index 3e562e49..ba4cd971 100644 --- a/pkg/generate/templates/lang_nodejs/.github/workflows/nodejs.yml.tmpl +++ b/pkg/generate/_templates/.github/workflows/ci-nodejs.part.tmpl @@ -1,56 +1,8 @@ -# Code generated by craft; DO NOT EDIT. - -name: Node -run-name: Node - -<<- $specifics := get .Languages "nodejs" >> -<<- $nodebuild := $specifics.Main >> -<<- $docker := and .Docker (gt .Binaries 0) >> -<<- $manager := cutAfter $specifics.PackageManager "@" >> - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging -<<- if and (not .IsAutoRelease) (or (not .CI.Static) (not .CI.Static.Auto)) >> - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x -<<- end >> - workflow_call: -<<- if $nodebuild >> - inputs: - build: - description: Whether to run build job or not - required: false - type: boolean -<<- end >> - workflow_dispatch: - jobs: +<<- define "node" >> - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT +<<- $specifics := get .Languages "node" >> +<<- $manager := cutAfter $specifics.PackageManager "@" >> <<- /* bun doesn't support audit yet: https://github.com/oven-sh/bun/issues/5359 */ ->> <<- if ne $manager "bun" >> @@ -63,6 +15,11 @@ jobs: - uses: actions/checkout@v4 <<- if eq $manager "pnpm" >> - uses: pnpm/action-setup@v4 +<<- end >> +<<- if eq $manager "bun" >> + - uses: oven-sh/setup-bun@v2 + with: + bun-version-file: package.json <<- end >> - uses: actions/setup-node@v4 with: @@ -116,8 +73,6 @@ jobs: - macos-latest - ubuntu-latest - windows-latest - env: - OS: ${{ matrix.os }} steps: - uses: actions/checkout@v4 <<- if eq $manager "pnpm" >> @@ -138,17 +93,18 @@ jobs: - run: << $manager >> ci <<- end >> <<- if eq $manager "bun" >> - - run: << $manager >> install --frozen-lockfile - - run: << $manager >> test --rerun-each 10 --coverage --coverage-reporter=lcov --coverage-dir=reports + - run: | + << $manager >> install --frozen-lockfile + << $manager >> test --rerun-each 10 --coverage --coverage-reporter=lcov --coverage-dir=reports <<- else if eq $manager "pnpm" >> - run: << $manager >> install-test --frozen-lockfile <<- else >> - - run: << $manager >> install --frozen-lockfile - - run: << $manager >> run test + - run: | + << $manager >> install --frozen-lockfile + << $manager >> run test <<- end >> <<- if has "codecov" .CI.Options >> - - if: ${{ ! startsWith(github.head_ref, 'dependabot') && ! startsWith(github.head_ref, 'renovate') }} - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v4 with: codecov_yml_path: .codecov.yml disable_search: true @@ -157,6 +113,8 @@ jobs: files: reports/lcov.info slug: ${{ github.repository }} token: ${{ secrets.CODECOV_TOKEN }} + env: + OS: ${{ matrix.os }} <<- end >> <<- if has "sonar" .CI.Options >> - uses: actions/upload-artifact@v4 @@ -166,14 +124,13 @@ jobs: retention-days: 1 <<- end >> -<<- if $nodebuild >> +<<- if gt .Binaries 0 >> node-build: name: Node Build runs-on: ubuntu-latest - if: ${{ inputs.build }} needs: - - run-workflow + - version - node-test steps: - uses: actions/checkout@v4 @@ -196,6 +153,8 @@ jobs: - run: << $manager >> install --frozen-lockfile <<- end >> - run: << $manager >> run build + env: + VERSION: ${{ needs.version.outputs.version }} <<- if .IsStatic "pages" >> - uses: actions/upload-pages-artifact@v3 with: @@ -209,47 +168,4 @@ jobs: path: dist retention-days: 1 <<- end >> - -<<- if has "sonar" .CI.Options >> - - sonar-analysis: - name: Sonar Analysis - runs-on: ubuntu-latest - needs: - - run-workflow - - node-lint - - node-test - env: - SONAR_USER_HOME: .sonar - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/download-artifact@v4 - - uses: actions/cache/restore@v4 - with: - path: ${{ env.SONAR_USER_HOME }} - key: sonar-cache - - if: ${{ github.event_name == 'pull_request' }} - uses: sonarsource/sonarcloud-github-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: | - -Dproject.settings=sonar.properties - -Dsonar.pullrequest.base=${{ github.base_ref }} - -Dsonar.pullrequest.branch=${{ github.head_ref }} - -Dsonar.pullrequest.key=${{ github.event.issue.number }} - - if: ${{ github.event_name == 'push' }} - uses: sonarsource/sonarcloud-github-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: | - -Dproject.settings=sonar.properties - -Dsonar.branch.name=${{ github.ref_name }} - - uses: actions/cache/save@v4 - with: - path: ${{ env.SONAR_USER_HOME }} - key: sonar-cache <<- end >> \ No newline at end of file diff --git a/pkg/generate/_templates/.github/workflows/ci.yml.tmpl b/pkg/generate/_templates/.github/workflows/ci.yml.tmpl new file mode 100644 index 00000000..fe2c0cda --- /dev/null +++ b/pkg/generate/_templates/.github/workflows/ci.yml.tmpl @@ -0,0 +1,350 @@ +# Code generated by craft; DO NOT EDIT. + +name: CICD +run-name: CICD + +<<- $node := hasKey .Languages "node" >> +<<- $hugo := hasKey .Languages "hugo" >> +<<- $golang := hasKey .Languages "golang" >> + +<<- $nodebuild := and $node (gt .Binaries 0) >> +<<- $nodepublish := and $node (not (get .Languages "node").Private) >> + +<<- $pages := and (.IsStatic "pages") (or $nodebuild $hugo) >> +<<- $netlify := and (.IsStatic "netlify") (or $nodebuild $hugo) >> + +<<- $auth := fromPtr .CI.Auth.Release >> + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + push: + branches: + - alpha + - beta + - dev + - develop + - development + - next + - staging + - main + - master + - v[0-9]+.x + - v[0-9]+.[0-9]+.x + workflow_dispatch: + inputs: + dry_run: + description: Whether to run all impacting jobs in dry run or preview mode. + type: boolean + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +<<- $checkout := list >> +<<- $plugins := list >> +<<- $envs := list >> + +<<- if .CI.Release >> + +<<- if eq $auth "github-app" >><<- $checkout = append $checkout "token: ${{ steps.app_token.outputs.token }}">><<- end >> +<<- if ne $auth "github-token" >><<- $checkout = append $checkout "persist-credentials: false">><<- end >> + +<<- if $node >><<- $plugins = append $plugins "@semantic-release/npm" >><<- end >> +<<- if .License >><<- $plugins = append $plugins "semantic-release-license" >><<- end >> +<<- if .CI.Release.Backmerge >><<- $plugins = append $plugins "@kilianpaquier/semantic-release-backmerge" >><<- end >> + +<<- if eq $auth "github-app" >><<- $envs = append $envs "GITHUB_TOKEN: ${{ steps.app_token.outputs.token }}" >> +<<- else if eq $auth "personal-token" >><<- $envs = append $envs "GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}" >> +<<- else >><<- $envs = append $envs "GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}" >><<- end >> +<<- if $nodepublish >><<- $envs = append $envs "NPM_TOKEN: ${{ secrets.NPM_TOKEN }}" >><<- end >> + +<<- end >> + +jobs: + run-workflow: + name: Run Workflow + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} + steps: + - id: skip + run: echo "Running workflow" + +<<- if or (gt .Binaries 0) $hugo .Docker >> + + version: + name: Version + runs-on: ubuntu-latest + needs: run-workflow + if: ${{ github.event_name != 'pull_request' }} + outputs: + version: ${{ steps.version.outputs.version }} + permissions: +<<- if eq $auth "github-token" >> + contents: write + issues: write + pull-requests: write +<<- end >> + id-token: << if $node >>write<< else >>none<< end >> + steps: +<<- if .CI.Release >> +<<- if eq $auth "github-app" >> + - id: app_token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.RELEASE_APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} +<<- end >> + - uses: actions/checkout@v4 + with: + fetch-depth: 0 +<<- range $checkout >> + << . >> +<<- end >> + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: true + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits +<<- range $plugins >> + << . >> +<<- end >> + env: +<<- range $envs >> + << . >> +<<- end >> + - id: version + run: | + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then + echo "version=v${SEMREL_INFO_NEXT_VERSION#v}" >> $GITHUB_OUTPUT + else + DESCRIBE=$(git describe --tags || echo "v0.0.0") + echo "version=v${DESCRIBE#v}" >> $GITHUB_OUTPUT + fi + env: + SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} +<<- else >> + - uses: actions/checkout@v4 + - id: version + run: | + DESCRIBE=$(git describe --tags || echo "v0.0.0") + echo "version=v${DESCRIBE#v}" >> $GITHUB_OUTPUT +<<- end >> + - run: echo ${VERSION} + env: + VERSION: ${{ steps.version.outputs.version }} +<<- end >> + +<<- if $golang >><< template "golang" . >><<- end >> +<<- if $hugo >><< template "hugo" . >><<- end >> +<<- if $node >><< template "node" . >><<- end >> + +<<- if has "sonar" .CI.Options >> + + sonar-analysis: + name: Sonar Analysis + runs-on: ubuntu-latest + needs: +<<- if $golang >> + - go-lint + - go-test +<<- end >> +<<- if $node >> + - node-lint + - node-test +<<- end >> + env: + SONAR_USER_HOME: .sonar + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: reports + - uses: actions/cache@v4 + with: + path: ${{ env.SONAR_USER_HOME }} + key: sonar-cache + - if: ${{ github.event_name == 'pull_request' }} + uses: sonarsource/sonarcloud-github-action@master + with: + args: | + -Dproject.settings=sonar.properties + -Dsonar.pullrequest.base=${{ github.base_ref }} + -Dsonar.pullrequest.branch=${{ github.head_ref }} + -Dsonar.pullrequest.key=${{ github.event.issue.number }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - if: ${{ github.event_name == 'push' }} + uses: sonarsource/sonarcloud-github-action@master + with: + args: | + -Dproject.settings=sonar.properties + -Dsonar.branch.name=${{ github.ref_name }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +<<- end >> + +<<- if .Docker >><< template "docker" . >><<- end >> + +<<- $needs := list >> + +<<- if $hugo >><<- $needs = append $needs "hugo-build" >><<- end >> + +<<- if $golang >> +<<- if gt .Binaries 0 >><<- $needs = append $needs "go-build" >> +<<- else >><<- $needs = append $needs "go-test" >><<- end >> +<<- end >> + +<<- if $node >> +<<- if gt .Binaries 0 >><<- $needs = append $needs "node-build" >> +<<- else >><<- $needs = append $needs "node-test" >><<- end >> +<<- end >> + +<<- if $netlify >> + + netlify: + name: Netlify + runs-on: ubuntu-latest + needs: +<<- range $needs >> + - << . >> +<<- end >> + environment: + name: netlify + url: ${{ steps.netlify.outputs.deploy-url }} + permissions: + deployments: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: build + path: dist + # https://github.com/marketplace/actions/netlify-actions + - id: branch_sha + run: | + echo "branch_sha=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8)" >> $GITHUB_OUTPUT + - id: netlify + uses: nwtgck/actions-netlify@v3 + with: + alias: ${{ steps.branch_sha.outputs.branch_sha }} + deploy-message: ${{ github.ref_name }} + enable-commit-comment: false + enable-commit-status: false + github-deployment-environment: netlify + github-token: ${{ secrets.GITHUB_TOKEN }} + netlify-config-path: netlify.toml + production-branch: ${{ github.event.repository.default_branch }} + publish-dir: dist + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} +<<- end >> + +<<- if $pages >> + + pages: + name: Pages + runs-on: ubuntu-latest + needs: +<<- range $needs >> + - << . >> +<<- end >> + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + id-token: write + pages: write + pull-request: write + steps: + - id: deployment + uses: actions/deploy-pages@v4 + with: + artifact_name: github-pages + preview: ${{ inputs.dry_run == 'true' || (github.event_name != 'workflow_dispatch' && github.ref_name != github.event.repository.default_branch) }} +<<- end >> + +<<- if .CI.Release >> + +<<- if .Docker >><<- $needs = append $needs "docker-build" >><<- end >> +<<- if $netlify >><<- $needs = append $needs "netlify" >><<- end >> +<<- if $pages >><<- $needs = append $needs "pages" >><<- end >> + + release: + name: Release + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref_protected == 'true' }} + environment: + name: release + url: ${{ github.server_url }}/${{ github.repository_owner }}/${{ github.repository }}/releases/tag/${{ steps.semrel_version.outputs.new_release_version }} + needs: +<<- range $needs >> + - << . >> +<<- end >> + permissions: +<<- if eq $auth "github-token" >> + contents: write + issues: write + pull-requests: write +<<- end >> + id-token: << if $node >>write<< else >>none<< end >> + steps: +<<- if eq $auth "github-app" >> + - id: app_token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.RELEASE_APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} +<<- end >> + - uses: actions/checkout@v4 + with: + fetch-depth: 0 +<<- range $checkout >> + << . >> +<<- end >> +<<- if gt .Binaries 0 >> + - uses: actions/download-artifact@v4 + with: + name: build + path: dist +<<- end >> + # https://github.com/marketplace/actions/action-for-semantic-release + - id: semrel_version + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: ${{ inputs.dry_run == 'true' }} + semantic_version: 24 + extra_plugins: | + @semantic-release/changelog + @semantic-release/commit-analyzer + @semantic-release/exec + @semantic-release/git + @semantic-release/github + @semantic-release/release-notes-generator + conventional-changelog-conventionalcommits +<<- range $plugins >> + << . >> +<<- end >> + env: +<<- range $envs >> + << . >> +<<- end >> +<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/.github/workflows/codeql.yml.tmpl b/pkg/generate/_templates/.github/workflows/codeql.yml.tmpl similarity index 88% rename from pkg/generate/templates/.github/workflows/codeql.yml.tmpl rename to pkg/generate/_templates/.github/workflows/codeql.yml.tmpl index 17330edd..a7d5d192 100644 --- a/pkg/generate/templates/.github/workflows/codeql.yml.tmpl +++ b/pkg/generate/_templates/.github/workflows/codeql.yml.tmpl @@ -10,19 +10,13 @@ # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. -# + name: CodeQL run-name: CodeQL <<- $languages := list >> - -<<- if hasKey .Languages "nodejs" >> -<<- $languages = append $languages "javascript-typescript" >> -<<- end >> - -<<- if or (hasKey .Languages "golang") (hasKey .Languages "hugo") >> -<<- $languages = append $languages "go" >> -<<- end >> +<<- if hasKey .Languages "node" >><<- $languages = append $languages "javascript-typescript" >><<- end >> +<<- if or (hasKey .Languages "golang") (hasKey .Languages "hugo") >><<- $languages = append $languages "go" >><<- end >> on: push: diff --git a/pkg/generate/templates/lang_golang/.github/workflows/dependencies.yml.tmpl b/pkg/generate/_templates/.github/workflows/dependencies.yml.tmpl similarity index 99% rename from pkg/generate/templates/lang_golang/.github/workflows/dependencies.yml.tmpl rename to pkg/generate/_templates/.github/workflows/dependencies.yml.tmpl index 8bc2167f..e1c14270 100644 --- a/pkg/generate/templates/lang_golang/.github/workflows/dependencies.yml.tmpl +++ b/pkg/generate/_templates/.github/workflows/dependencies.yml.tmpl @@ -19,7 +19,6 @@ on: - v[0-9]+.x jobs: - go-dependency-submission: name: Go Dependency Submission runs-on: ubuntu-latest diff --git a/pkg/generate/templates/.github/workflows/labeler.yml.tmpl b/pkg/generate/_templates/.github/workflows/labeler.yml.tmpl similarity index 81% rename from pkg/generate/templates/.github/workflows/labeler.yml.tmpl rename to pkg/generate/_templates/.github/workflows/labeler.yml.tmpl index a729aada..8267a228 100644 --- a/pkg/generate/templates/.github/workflows/labeler.yml.tmpl +++ b/pkg/generate/_templates/.github/workflows/labeler.yml.tmpl @@ -9,17 +9,13 @@ on: - opened - reopened - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize + - ready_for_review jobs: - labeler: name: Labeler runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected == false) }} permissions: contents: read # enfore rights to specify no release, even draft, is created pull-requests: write diff --git a/pkg/generate/templates/.github/workflows/renovate.yml.tmpl b/pkg/generate/_templates/.github/workflows/renovate.yml.tmpl similarity index 92% rename from pkg/generate/templates/.github/workflows/renovate.yml.tmpl rename to pkg/generate/_templates/.github/workflows/renovate.yml.tmpl index 3855f80a..40a25b1d 100644 --- a/pkg/generate/templates/.github/workflows/renovate.yml.tmpl +++ b/pkg/generate/_templates/.github/workflows/renovate.yml.tmpl @@ -9,14 +9,13 @@ on: workflow_dispatch: inputs: dry_run: - description: Dry run + description: Whether to only run renovate job in dry run mode or let renovate create pull requests. type: boolean default: false schedule: - cron: "0 12 * * *" jobs: - renovate: name: Renovate runs-on: ubuntu-latest diff --git a/pkg/generate/templates/lang_golang/.gitignore.tmpl b/pkg/generate/_templates/.gitignore-golang.part.tmpl similarity index 70% rename from pkg/generate/templates/lang_golang/.gitignore.tmpl rename to pkg/generate/_templates/.gitignore-golang.part.tmpl index b3c00277..116b73c5 100644 --- a/pkg/generate/templates/lang_golang/.gitignore.tmpl +++ b/pkg/generate/_templates/.gitignore-golang.part.tmpl @@ -1,4 +1,4 @@ -# Code generated by craft; DO NOT EDIT. +{{- define "golang" }} # If you prefer the allow list template instead of the deny list, see community template: # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore @@ -30,22 +30,23 @@ reports/ .env # binaries -<<- range $name, $config := .Clis >> -<< $name >> -<< printf "!%s/" $name >> -<<- end >> +{{- range $name, $config := .Clis }} +{{ $name }} +{{ printf "!%s/" $name }} +{{- end }} -<<- if gt (len .Crons) 0 >> +{{- if gt (len .Crons) 0 }} cron-* !cron-*/ -<<- end >> +{{- end }} -<<- if gt (len .Jobs) 0 >> +{{- if gt (len .Jobs) 0 }} job-* !job-*/ -<<- end >> +{{- end }} -<<- if gt (len .Workers) 0 >> +{{- if gt (len .Workers) 0 }} worker-* !worker-*/ -<<- end >> \ No newline at end of file +{{- end }} +{{- end }} \ No newline at end of file diff --git a/testdata/hugo/success_bot_github_renovate/.gitignore b/pkg/generate/_templates/.gitignore-hugo.part.tmpl similarity index 78% rename from testdata/hugo/success_bot_github_renovate/.gitignore rename to pkg/generate/_templates/.gitignore-hugo.part.tmpl index 7ea3eae6..5ec42602 100644 --- a/testdata/hugo/success_bot_github_renovate/.gitignore +++ b/pkg/generate/_templates/.gitignore-hugo.part.tmpl @@ -1,4 +1,4 @@ -# Code generated by craft; DO NOT EDIT. +{{- define "hugo" }} # Generated files by hugo /assets/jsconfig.json @@ -13,4 +13,5 @@ hugo.darwin hugo.linux # Temporary lock file while building -/.hugo_build.lock \ No newline at end of file +/.hugo_build.lock +{{- end }} \ No newline at end of file diff --git a/testdata/nodejs/success_both_github_renovate/.gitignore b/pkg/generate/_templates/.gitignore-nodejs.part.tmpl similarity index 97% rename from testdata/nodejs/success_both_github_renovate/.gitignore rename to pkg/generate/_templates/.gitignore-nodejs.part.tmpl index ef7f4401..855278dc 100644 --- a/testdata/nodejs/success_both_github_renovate/.gitignore +++ b/pkg/generate/_templates/.gitignore-nodejs.part.tmpl @@ -1,4 +1,4 @@ -# Code generated by craft; DO NOT EDIT. +{{- define "node" }} # Logs logs @@ -130,4 +130,5 @@ dist .yarn/unplugged .yarn/build-state.yml .yarn/install-state.gz -.pnp.* \ No newline at end of file +.pnp.* +{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/.gitignore.tmpl b/pkg/generate/_templates/.gitignore.tmpl new file mode 100644 index 00000000..a23702a0 --- /dev/null +++ b/pkg/generate/_templates/.gitignore.tmpl @@ -0,0 +1,11 @@ +# Code generated by craft; DO NOT EDIT. + +{{- if hasKey .Languages "hugo" }}{{ template "hugo" . }}{{- end }} +{{- if hasKey .Languages "golang" }}{{ template "golang" . }}{{- end }} +{{- if hasKey .Languages "node" }}{{ template "node" . }}{{- end }} + +{{- if .IsStatic "netlify" }} + +# Local Netlify folder +.netlify +{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/.gitlab-ci.yml.tmpl b/pkg/generate/_templates/.gitlab-ci.yml.tmpl similarity index 84% rename from pkg/generate/templates/.gitlab-ci.yml.tmpl rename to pkg/generate/_templates/.gitlab-ci.yml.tmpl index f35bbacf..cee91353 100644 --- a/pkg/generate/templates/.gitlab-ci.yml.tmpl +++ b/pkg/generate/_templates/.gitlab-ci.yml.tmpl @@ -1,15 +1,11 @@ # Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. -<<- $nodejs := hasKey .Languages "nodejs" >> +<<- $node := hasKey .Languages "node" >> <<- $hugo := hasKey .Languages "hugo" >> <<- $golang := hasKey .Languages "golang" >> -<<- $gocli := and $golang (gt (len .Clis) 0) (not .NoGoreleaser) >> -<<- $docker := and .Docker (gt .Binaries 0) >> - -<<- $pages := and (.IsStatic "pages") (or $nodejs $hugo) >> -<<- $netlify := and (.IsStatic "netlify") (or $nodejs $hugo) >> +<<- $pages := and (.IsStatic "pages") (or $node $hugo) >> +<<- $netlify := and (.IsStatic "netlify") (or $node $hugo) >> --- include: .gitlab/workflows/.gitlab-ci.yml @@ -20,7 +16,7 @@ include: .gitlab/workflows/.gitlab-ci.yml # GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. # SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). -<<- if and $docker .Docker.Registry >> +<<- if and .Docker .Docker.Registry >> # CI_REGISTRY_USER: The user with write access to << .Docker.Registry >> to push docker images # CI_REGISTRY_PASSWORD: The user password / token with write access to << .Docker.Registry >> to push docker images diff --git a/pkg/generate/_templates/.gitlab/semrel-plugins.txt.tmpl b/pkg/generate/_templates/.gitlab/semrel-plugins.txt.tmpl new file mode 100644 index 00000000..fc93111e --- /dev/null +++ b/pkg/generate/_templates/.gitlab/semrel-plugins.txt.tmpl @@ -0,0 +1,13 @@ +{{- $plugins := list }} +{{- if hasKey .Languages "node" }}{{- $plugins = append $plugins "@semantic-release/npm" }}{{- end }} +{{- if .License }}{{- $plugins = append $plugins "semantic-release-license" }}{{- end }} +{{- if .CI.Release.Backmerge }}{{- $plugins = append $plugins "@kilianpaquier/semantic-release-backmerge" }}{{- end }} + +@semantic-release/changelog +@semantic-release/commit-analyzer +@semantic-release/exec +@semantic-release/git +@semantic-release/gitlab +{{- range $plugins }} +{{ . }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/.gitlab/workflows/.gitlab-ci.yml.tmpl b/pkg/generate/_templates/.gitlab/workflows/.gitlab-ci.yml.tmpl similarity index 77% rename from pkg/generate/templates/.gitlab/workflows/.gitlab-ci.yml.tmpl rename to pkg/generate/_templates/.gitlab/workflows/.gitlab-ci.yml.tmpl index f942c2b1..90003223 100644 --- a/pkg/generate/templates/.gitlab/workflows/.gitlab-ci.yml.tmpl +++ b/pkg/generate/_templates/.gitlab/workflows/.gitlab-ci.yml.tmpl @@ -1,14 +1,11 @@ # Code generated by craft; DO NOT EDIT. -<<- $nodejs := hasKey .Languages "nodejs" >> +<<- $node := hasKey .Languages "node" >> <<- $hugo := hasKey .Languages "hugo" >> <<- $golang := hasKey .Languages "golang" >> -<<- $gocli := and $golang (gt (len .Clis) 0) (not .NoGoreleaser) >> -<<- $docker := and .Docker (gt .Binaries 0) >> - -<<- $pages := and (.IsStatic "pages") (or $nodejs $hugo) >> -<<- $netlify := and (.IsStatic "netlify") (or $nodejs $hugo) >> +<<- $pages := and (.IsStatic "pages") (or $node $hugo) >> +<<- $netlify := and (.IsStatic "netlify") (or $node $hugo) >> --- include: @@ -26,7 +23,7 @@ include: file: "templates/gitlab-ci-renovate.yml" <<- end >> -<<- if $docker >> +<<- if .Docker >> # Docker template - project: "to-be-continuous/docker" @@ -42,7 +39,7 @@ include: file: "templates/gitlab-ci-golang.yml" <<- end >> -<<- if $nodejs >> +<<- if $node >> # Node.js template - project: "to-be-continuous/node" @@ -65,7 +62,7 @@ variables: RENOVATE_AUTODISCOVER_FILTER: ${CI_PROJECT_PATH} <<- end >> -<<- if $docker >> +<<- if .Docker >> <<- if .Docker.Registry >> CI_REGISTRY: << .Docker.Registry >> @@ -87,7 +84,7 @@ variables: DOCKER_TRIVY_SECURITY_LEVEL_THRESHOLD: "MEDIUM,HIGH,CRITICAL" <<- end >> -<<- if $nodejs >> +<<- if $node >> NODE_AUDIT_DISABLED: "false" NODE_BUILD_ARGS: "run build --prod" @@ -135,50 +132,37 @@ variables: SEMREL_AUTO_RELEASE_ENABLED: << if .IsAutoRelease >>"true"<< else >>"false"<< end >> semantic-release-info: + variables: + GIT_DEPTH: "0" after_script: - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then + echo "BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8)" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + + if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 + else + DESCRIBE=$(git describe --tags || echo "v1.0.0") + echo "SEMREL_INFO_NEXT_VERSION=v${DESCRIBE#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" + echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" -<<- if and .CI.Release .CI.Release.Backmerge >> - semantic-release: variables: GIT_DEPTH: "0" -<<- end >> -<<- if $gocli >> +<<- if $golang >> go-build: image: ghcr.io/goreleaser/goreleaser:latest + rules: + # https://gitlab.com/to-be-continuous/golang/-/blob/master/templates/gitlab-ci-golang.yml?ref_type=heads#L651 + - if: $GO_TEST_IMAGE != "" + exists: + - .goreleaser.yml script: - goreleaser release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot artifacts: @@ -190,10 +174,6 @@ go-build: - dist/*.yaml - dist/*/ expire_in: 1 day -<<- else if $golang >> - -go-build: - when: never <<- end >> <<- if $hugo >> @@ -252,7 +232,7 @@ netlify: when: manual <<- end >> - variables: - ARGS: "--alias $BRANCH_SHA" # sha is coming from version.yml file with export from semantic-release-info job + ARGS: "--alias $BRANCH_SHA" ENV: $CI_COMMIT_REF_NAME when: manual before_script: diff --git a/pkg/generate/templates/lang_golang/.golangci.yml.tmpl b/pkg/generate/_templates/.golangci.yml.tmpl similarity index 100% rename from pkg/generate/templates/lang_golang/.golangci.yml.tmpl rename to pkg/generate/_templates/.golangci.yml.tmpl diff --git a/pkg/generate/templates/lang_golang/.goreleaser.yml.tmpl b/pkg/generate/_templates/.goreleaser.yml.tmpl similarity index 100% rename from pkg/generate/templates/lang_golang/.goreleaser.yml.tmpl rename to pkg/generate/_templates/.goreleaser.yml.tmpl diff --git a/pkg/generate/templates/.releaserc.yml.tmpl b/pkg/generate/_templates/.releaserc.yml.tmpl similarity index 85% rename from pkg/generate/templates/.releaserc.yml.tmpl rename to pkg/generate/_templates/.releaserc.yml.tmpl index 35e4cd94..66738951 100644 --- a/pkg/generate/templates/.releaserc.yml.tmpl +++ b/pkg/generate/_templates/.releaserc.yml.tmpl @@ -2,11 +2,9 @@ # https://semantic-release.gitbook.io/semantic-release/usage/configuration -<<- $nodejs := hasKey .Languages "nodejs" >> -<<- $hugo := hasKey .Languages "hugo" >> -<<- $golang := hasKey .Languages "golang" >> - -<<- $gocli := and $golang (gt (len .Clis) 0) (not .NoGoreleaser) >> +{{- $node := hasKey .Languages "node" }} +{{- $hugo := hasKey .Languages "hugo" }} +{{- $golang := hasKey .Languages "golang" }} branches: - (master|main) @@ -80,24 +78,24 @@ plugins: - BREAKING CHANGES - BREAKING - "@semantic-release/changelog" -<<- if .License >> +{{- if .License }} - "semantic-release-license" -<<- end >> -<<- if $nodejs >> +{{- end }} +{{- if $node }} - "@semantic-release/npm" -<<- end >> +{{- end }} - - "@semantic-release/git" - assets: - CHANGELOG.md -<<- if .License >> +{{- if .License }} - LICENSE -<<- end >> -<<- if $nodejs >> +{{- end }} +{{- if $node }} - package.json -<<- end >> +{{- end }} message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" -<<- if .IsCI "github" >> - - - "@semantic-release/<< .CI.Name >>" +{{- if .IsCI "github" }} + - - "@semantic-release/{{ .CI.Name }}" - draftRelease: false failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} failCommentCondition: <% return false; %> @@ -106,13 +104,12 @@ plugins: assets: - label: CHANGELOG.md path: CHANGELOG.md -<<- if $gocli >> - - path: checksums.txt +{{- if gt .Binaries 0 }} - path: dist -<<- end >> -<<- end >> -<<- if .IsCI "gitlab" >> - - - "@semantic-release/<< .CI.Name >>" +{{- end }} +{{- end }} +{{- if .IsCI "gitlab" }} + - - "@semantic-release/{{ .CI.Name }}" - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} failCommentCondition: <% return false; %> successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 @@ -120,12 +117,11 @@ plugins: assets: - label: CHANGELOG.md path: CHANGELOG.md -<<- if $gocli >> - - path: checksums.txt +{{- if gt .Binaries 0 }} - path: dist -<<- end >> -<<- end >> -<<- if .CI.Release.Backmerge >> +{{- end }} +{{- end }} +{{- if .CI.Release.Backmerge }} - - "@kilianpaquier/semantic-release-backmerge" - targets: - from: ^(master|main)$ @@ -134,8 +130,7 @@ plugins: to: ^(dev|develop|development)$ - from: staging to: ^(dev|develop|development)$ -<<- if ne .CI.Name .Platform >> - platform: << .Platform >> -<<- end >> -<<- end >> - - "@semantic-release/exec" \ No newline at end of file +{{- if ne .CI.Name .Platform }} + platform: {{ .Platform }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/Dockerfile-golang.part.tmpl b/pkg/generate/_templates/Dockerfile-golang.part.tmpl new file mode 100644 index 00000000..32415d08 --- /dev/null +++ b/pkg/generate/_templates/Dockerfile-golang.part.tmpl @@ -0,0 +1,73 @@ +{{- define "golang" }} + +{{- $specifics := get .Languages "golang" }} + +{{- $binaries := dict }} +{{- $_ := map $binaries .Clis .Crons .Jobs .Workers }} + +{{- $maintainer := index .Maintainers 0 }} + +############################# +# STAGE BUILD # +############################# +FROM golang:{{ $specifics.LangVersion }} AS build + +WORKDIR /app + +COPY . . + +# hadolint ignore=DL3059 +RUN go mod download + +{{- range $name, $config := $binaries }} +# hadolint ignore=DL3059 +RUN CGO_ENABLED=0 go build -o {{ $name }} cmd/{{ $name }}/main.go +{{- end }} + +############################# +# STAGE RUN # +############################# +FROM gcr.io/distroless/static-debian12:nonroot + +LABEL org.opencontainers.image.authors="{{ $maintainer.Name }}{{ if $maintainer.Email }} <{{ $maintainer.Email }}>{{ end }}" +LABEL org.opencontainers.image.vendor="{{ $maintainer.Name }}" + +LABEL org.opencontainers.image.title="{{ .ProjectName }}" +{{- if .Description }} +LABEL org.opencontainers.image.description="{{ .Description }}" +{{- end }} +{{- if .License }} +LABEL org.opencontainers.image.licenses="{{ upper .License }}" +{{- end }} +LABEL org.opencontainers.image.url="{{ print .ProjectHost "/" .ProjectPath }}" +LABEL org.opencontainers.image.source="{{ print .ProjectHost "/" .ProjectPath }}" +LABEL org.opencontainers.image.documentation="{{ print .ProjectHost "/" .ProjectPath }}" + +WORKDIR /app + +COPY --from=build \ +{{- range $name, $config := $binaries }} + /app/{{ $name }} \ +{{- end }} + ./ + +{{- $entrypoint := "launcher.sh" }} + +{{- if eq .Binaries 1 }} + +{{- /* directly use the only binary */ -}} +{{- range $name, $config := $binaries }} +{{- $entrypoint = $name }} +{{- end }} + +{{- end }} + +{{- /* copy launcher if the entrypoint is the launcher */ -}} +{{- if eq $entrypoint "launcher.sh" }} +COPY launcher.sh launcher.sh +{{- end }} + +EXPOSE {{ .Docker.Port | default 3000 }} + +ENTRYPOINT [ "/app/{{ $entrypoint }}" ] +{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/Dockerfile.tmpl b/pkg/generate/_templates/Dockerfile.tmpl new file mode 100644 index 00000000..150dcdcf --- /dev/null +++ b/pkg/generate/_templates/Dockerfile.tmpl @@ -0,0 +1,3 @@ +# Code generated by craft; DO NOT EDIT. + +{{- if hasKey .Languages "golang" }}{{ template "golang" . }}{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/Makefile.tmpl b/pkg/generate/_templates/Makefile.tmpl similarity index 51% rename from pkg/generate/templates/Makefile.tmpl rename to pkg/generate/_templates/Makefile.tmpl index b40311bc..59e18bf1 100644 --- a/pkg/generate/templates/Makefile.tmpl +++ b/pkg/generate/_templates/Makefile.tmpl @@ -1,4 +1,3 @@ # Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. include ./scripts/*.mk \ No newline at end of file diff --git a/pkg/generate/_templates/README.md.tmpl b/pkg/generate/_templates/README.md.tmpl new file mode 100644 index 00000000..849eb7cc --- /dev/null +++ b/pkg/generate/_templates/README.md.tmpl @@ -0,0 +1,42 @@ +# {{ .ProjectName }} + +

+{{- $style := "for-the-badge" }} +{{- $branch := "main" }} + +{{- if eq .Platform "github" }} + GitHub Release + GitHub Issues +{{- if .License }} + GitHub License +{{- end }} +{{- end }} + +{{- if eq .Platform "gitlab" }} +{{- $url := toQuery (print "https://" .ProjectHost) }} + GitLab Release + GitLab Issues +{{- if .License }} + GitLab License +{{- end }} +{{- end }} + +{{- if has "codecov" .CI.Options }} + Coverage +{{- end }} + +{{- if has "sonar" .CI.Options }} +{{- $url := toQuery "https://sonarcloud.io" }} + Coverage +{{- end }} + +{{- if or (hasKey .Languages "golang") (hasKey .Languages "hugo") }} + Go Version +{{- end }} + +{{- if hasKey .Languages "golang" }} + Go Report Card +{{- end }} +

+ +--- \ No newline at end of file diff --git a/pkg/generate/templates/lang_helm/.craft.tmpl b/pkg/generate/_templates/chart/.craft.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/.craft.tmpl rename to pkg/generate/_templates/chart/.craft.tmpl diff --git a/pkg/generate/templates/lang_helm/.helmignore.tmpl b/pkg/generate/_templates/chart/.helmignore.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/.helmignore.tmpl rename to pkg/generate/_templates/chart/.helmignore.tmpl diff --git a/pkg/generate/templates/lang_helm/Chart.yaml.tmpl b/pkg/generate/_templates/chart/Chart.yaml.tmpl similarity index 74% rename from pkg/generate/templates/lang_helm/Chart.yaml.tmpl rename to pkg/generate/_templates/chart/Chart.yaml.tmpl index 2621e6a0..1a94a76a 100644 --- a/pkg/generate/templates/lang_helm/Chart.yaml.tmpl +++ b/pkg/generate/_templates/chart/Chart.yaml.tmpl @@ -1,8 +1,10 @@ # Code generated by craft; DO NOT EDIT. +{{- $chart := get .Languages "helm" }} + apiVersion: v2 -name: << .projectName >> -description: << .description | default "A Helm chart for Kubernetes" >> +name: {{ $chart.projectName }} +description: {{ $chart.description | default "A Helm chart for Kubernetes" }} # A chart can be either an 'application' or a 'library' chart. # @@ -25,21 +27,21 @@ version: 0.1.0 # It is recommended to use it with quotes. appVersion: "0.1.0" -<<- with .dependencies >> +{{- with $chart.dependencies }} dependencies: -<<- range . >> - - name: << .name >> - version: << .version | default "v1.0.0" >> - repository: << .repository >> -<<- end >> -<<- else >> +{{- range . }} + - name: {{ .name }} + version: {{ .version | default "v1.0.0" }} + repository: {{ .repository }} +{{- end }} +{{- else }} dependencies: [] -<<- end >> +{{- end }} -<<- with .maintainers >> +{{- with $chart.maintainers }} maintainers: - <<- toYaml . | nindent 2 >> -<<- end >> + {{- toYaml . | nindent 2 }} +{{- end }} diff --git a/pkg/generate/templates/lang_helm/charts/.gitkeep.tmpl b/pkg/generate/_templates/chart/charts/.gitkeep.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/charts/.gitkeep.tmpl rename to pkg/generate/_templates/chart/charts/.gitkeep.tmpl diff --git a/pkg/generate/templates/lang_helm/templates/_helpers.tpl.tmpl b/pkg/generate/_templates/chart/templates/_helpers.tpl.tmpl similarity index 68% rename from pkg/generate/templates/lang_helm/templates/_helpers.tpl.tmpl rename to pkg/generate/_templates/chart/templates/_helpers.tpl.tmpl index 473effdd..8338658d 100644 --- a/pkg/generate/templates/lang_helm/templates/_helpers.tpl.tmpl +++ b/pkg/generate/_templates/chart/templates/_helpers.tpl.tmpl @@ -1,9 +1,11 @@ # Code generated by craft; DO NOT EDIT. +<<- $chart := get .Languages "helm" >> + {{/* Expand the name of the chart. */}} -{{- define "<< .projectName >>.name" -}} +{{- define "<< $chart.projectName >>.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -12,7 +14,7 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). If release name contains chart name it will be used as a full name. */}} -{{- define "<< .projectName >>.fullname" -}} +{{- define "<< $chart.projectName >>.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -28,16 +30,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "<< .projectName >>.chart" -}} +{{- define "<< $chart.projectName >>.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "<< .projectName >>.labels" -}} -helm.sh/chart: {{ include "<< .projectName >>.chart" . }} -{{ include "<< .projectName >>.selectorLabels" . }} +{{- define "<< $chart.projectName >>.labels" -}} +helm.sh/chart: {{ include "<< $chart.projectName >>.chart" . }} +{{ include "<< $chart.projectName >>.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -47,17 +49,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "<< .projectName >>.selectorLabels" -}} -app.kubernetes.io/name: {{ include "<< .projectName >>.name" . }} +{{- define "<< $chart.projectName >>.selectorLabels" -}} +app.kubernetes.io/name: {{ include "<< $chart.projectName >>.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "<< .projectName >>.serviceAccountName" -}} +{{- define "<< $chart.projectName >>.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "<< .projectName >>.fullname" .) .Values.serviceAccount.name }} +{{- default (include "<< $chart.projectName >>.fullname" .) .Values.serviceAccount.name }} {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} diff --git a/pkg/generate/templates/lang_helm/templates/configmap.yaml.tmpl b/pkg/generate/_templates/chart/templates/configmap.yaml.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/templates/configmap.yaml.tmpl rename to pkg/generate/_templates/chart/templates/configmap.yaml.tmpl diff --git a/pkg/generate/templates/lang_helm/templates/cronjob.yaml.tmpl b/pkg/generate/_templates/chart/templates/cronjob.yaml.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/templates/cronjob.yaml.tmpl rename to pkg/generate/_templates/chart/templates/cronjob.yaml.tmpl diff --git a/pkg/generate/templates/lang_helm/templates/deployment.yaml.tmpl b/pkg/generate/_templates/chart/templates/deployment.yaml.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/templates/deployment.yaml.tmpl rename to pkg/generate/_templates/chart/templates/deployment.yaml.tmpl diff --git a/pkg/generate/templates/lang_helm/templates/hpa.yaml.tmpl b/pkg/generate/_templates/chart/templates/hpa.yaml.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/templates/hpa.yaml.tmpl rename to pkg/generate/_templates/chart/templates/hpa.yaml.tmpl diff --git a/pkg/generate/templates/lang_helm/templates/job.yaml.tmpl b/pkg/generate/_templates/chart/templates/job.yaml.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/templates/job.yaml.tmpl rename to pkg/generate/_templates/chart/templates/job.yaml.tmpl diff --git a/pkg/generate/templates/lang_helm/templates/service.yaml.tmpl b/pkg/generate/_templates/chart/templates/service.yaml.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/templates/service.yaml.tmpl rename to pkg/generate/_templates/chart/templates/service.yaml.tmpl diff --git a/pkg/generate/templates/lang_helm/templates/serviceaccount.yaml.tmpl b/pkg/generate/_templates/chart/templates/serviceaccount.yaml.tmpl similarity index 100% rename from pkg/generate/templates/lang_helm/templates/serviceaccount.yaml.tmpl rename to pkg/generate/_templates/chart/templates/serviceaccount.yaml.tmpl diff --git a/pkg/generate/_templates/chart/values-cronjobs.part.tmpl b/pkg/generate/_templates/chart/values-cronjobs.part.tmpl new file mode 100644 index 00000000..a1863907 --- /dev/null +++ b/pkg/generate/_templates/chart/values-cronjobs.part.tmpl @@ -0,0 +1,161 @@ +{{- define "cronjobs" }} + +{{- $kubeVersion := "v1.30" }} + +{{- with .crons }} +crons: +{{- range $name, $config := . }} + {{ $name }}: + suspend: true + schedule: {{ $config.schedule | default "*/1 * * * *" | quote }} + concurrencyPolicy: {{ $config.concurrencyPolicy | default "Forbid" }} + completionMode: {{ $config.completionMode | default "NonIndexed" }} + completions: {{ $config.completions | default 1 }} + parallelism: {{ $config.parallelism | default 1 }} + image: + registry: {{ $config.image.registry | default $.docker.registry | default ("" | quote) }} + repository: {{ $config.image.repository | default $.projectPath }} + pullPolicy: {{ $config.image.pullPolicy | default ("" | quote) }} + # Overrides the image tag whose default is the chart appVersion. + tag: {{ $config.image.tag | default "" | quote }} + env: + {{- $env := merge (dict "BINARY_NAME" $name) (dict "BINARY_PORT" ($.docker.port | default 3000)) $config.env }} + {{- toYaml $env | nindent 6 }} + {{- with $config.envFrom }} + envFrom: + {{- toYaml . | nindent 6 }} + {{- else }} + envFrom: [] + # - prefix: "" + # configMapRef: + # name: "" + # secretRef: + # name: "" + {{- end }} + resources: + limits: + cpu: {{ $config.resources.limits.cpu | default "250m" }} + memory: {{ $config.resources.limits.memory | default "256Mi" }} + storage: {{ $config.resources.limits.storage | default "10Gi" }} + requests: + cpu: {{ $config.resources.requests.cpu | default "50m" }} + memory: {{ $config.resources.requests.memory | default "128Mi" }} + storage: {{ $config.resources.requests.storage | default "5Gi" }} + failedJobsHistoryLimit: {{ $config.failedJobsHistoryLimit | default 1 }} + successfulJobsHistoryLimit: {{ $config.successfulJobsHistoryLimit | default 3 }} + restartPolicy: {{ $config.restartPolicy | default "OnFailure" }} + {{- with $config.configMap }} + configMap: + {{- toYaml . | nindent 6 }} + {{- else }} + configMap: {} + # mountPath: /etc/config/ + # tpl_folders: # folders to be included in configmap with tpl + # - folder_name + # include_folders: # folders to be included in configmap without tpl + # - folder_name + # data: + # name: value + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#volume-v1-core + {{- with $config.volumes }} + volumes: + {{- toYaml . | nindent 6 }} + {{- else }} + volumes: [] + # - name: "" + # configMap: + # name: configMapName + # - name: "" + # emptyDir: + # medium: "" + # sizeLimit: 1Gi + # - name: "" + # persistentVolumeClaim: + # claimName: "" + # readOnly: false + # - name: "" + # secret: + # secretName: "" + {{- end }} + {{- with $config.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 6 }} + {{- else }} + volumeMounts: [] + # - mountPath: /etc/config/ + # name: volume[*].name + # readOnly: true + {{- end }} + + {{ with $config.podAnnotations -}} + podAnnotations: + {{- toYaml . | nindent 6 }} + {{ else -}} + podAnnotations: {} + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#podsecuritycontext-v1-core + {{- with $config.podSecurityContext }} + podSecurityContext: + {{- toYaml . | nindent 6 }} + {{- else }} + podSecurityContext: {} + {{- end }} + # fsGroup: 2 + # fsGroupChangePolicy: Always | OnRootMismatch + # runAsGroup: 1001 + # runAsNonRoot: true + # runAsUser: 1001 + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#securitycontext-v1-core + {{- with $config.securityContext }} + securityContext: + {{- toYaml . | nindent 6 }} + {{- else }} + securityContext: {} + # allowPrivilegeEscalation: false + # capabilities: + # add: [] + # drop: [] + # privileged: false + # readOnlyRootFilesystem: true + # runAsGroup: 1001 + # runAsNonRoot: true + # runAsUser: 1001 + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#nodeselector-v1-core + {{ with $config.nodeSelector -}} + nodeSelector: + {{- toYaml . | nindent 6 }} + {{ else -}} + nodeSelector: {} + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#toleration-v1-core + {{- with $config.tolerations }} + tolerations: + {{- toYaml . | nindent 6 }} + {{- else }} + tolerations: [] + # - effect: NoSchedule | PreferNoSchedule | NoExecute + # key: "" + # operator: Exists | Equal + # tolerationSeconds: 600 + # value: "" + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#affinity-v1-core + {{- with $config.affinity }} + affinity: + {{- toYaml . | nindent 6 }} + {{- else }} + affinity: {} + {{- end }} +{{ end }} +{{- else }} +crons: {} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/chart/values-jobs.part.tmpl b/pkg/generate/_templates/chart/values-jobs.part.tmpl new file mode 100644 index 00000000..fa03c58c --- /dev/null +++ b/pkg/generate/_templates/chart/values-jobs.part.tmpl @@ -0,0 +1,160 @@ +{{- define "jobs" }} + +{{- $kubeVersion := "v1.30" }} + +{{- with .jobs }} +jobs: +{{- range $name, $config := . }} + {{ $name }}: + suspend: true + completionMode: {{ $config.completionMode | default "NonIndexed" }} + completions: {{ $config.completions | default 1 }} + parallelism: {{ $config.parallelism | default 1 }} + {{- with $config.ttlSecondsAfterFinished }} + ttlSecondsAfterFinished: {{ . }} + {{- end }} + image: + registry: {{ $config.image.registry | default $.docker.registry | default ("" | quote) }} + repository: {{ $config.image.repository | default $.projectPath }} + pullPolicy: {{ $config.image.pullPolicy | default ("" | quote) }} + # Overrides the image tag whose default is the chart appVersion. + tag: {{ $config.image.tag | default "" | quote }} + env: + {{- $env := merge (dict "BINARY_NAME" $name) (dict "BINARY_PORT" ($.docker.port | default 3000)) $config.env }} + {{- toYaml $env | nindent 6 }} + {{- with $config.envFrom }} + envFrom: + {{- toYaml . | nindent 6 }} + {{- else }} + envFrom: [] + # - prefix: "" + # configMapRef: + # name: "" + # secretRef: + # name: "" + {{- end }} + resources: + limits: + cpu: {{ $config.resources.limits.cpu | default "250m" }} + memory: {{ $config.resources.limits.memory | default "256Mi" }} + storage: {{ $config.resources.limits.storage | default "10Gi" }} + requests: + cpu: {{ $config.resources.requests.cpu | default "50m" }} + memory: {{ $config.resources.requests.memory | default "128Mi" }} + storage: {{ $config.resources.requests.storage | default "5Gi" }} + restartPolicy: {{ $config.RestartPolicy | default "OnFailure" }} + {{- with $config.configMap }} + configMap: + {{- toYaml . | nindent 6 }} + {{- else }} + configMap: {} + # mountPath: /etc/config/ + # tpl_folders: # folders to be included in configmap with tpl + # - folder_name + # include_folders: # folders to be included in configmap without tpl + # - folder_name + # data: + # name: value + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#volume-v1-core + {{- with $config.volumes }} + volumes: + {{- toYaml . | nindent 6 }} + {{- else }} + volumes: [] + # - name: "" + # configMap: + # name: configMapName + # - name: "" + # emptyDir: + # medium: "" + # sizeLimit: 1Gi + # - name: "" + # persistentVolumeClaim: + # claimName: "" + # readOnly: false + # - name: "" + # secret: + # secretName: "" + {{- end }} + {{- with $config.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 6 }} + {{- else }} + volumeMounts: [] + # - mountPath: /etc/config/ + # name: volume[*].name + # readOnly: true + {{- end }} + + {{ with $config.podAnnotations -}} + podAnnotations: + {{- toYaml . | nindent 6 }} + {{ else -}} + podAnnotations: {} + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#podsecuritycontext-v1-core + {{- with $config.podSecurityContext }} + podSecurityContext: + {{- toYaml . | nindent 6 }} + {{- else }} + podSecurityContext: {} + {{- end }} + # fsGroup: 2 + # fsGroupChangePolicy: Always | OnRootMismatch + # runAsGroup: 1001 + # runAsNonRoot: true + # runAsUser: 1001 + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#securitycontext-v1-core + {{- with $config.securityContext }} + securityContext: + {{- toYaml . | nindent 6 }} + {{- else }} + securityContext: {} + # allowPrivilegeEscalation: false + # capabilities: + # add: [] + # drop: [] + # privileged: false + # readOnlyRootFilesystem: true + # runAsGroup: 1001 + # runAsNonRoot: true + # runAsUser: 1001 + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#nodeselector-v1-core + {{ with $config.nodeSelector -}} + nodeSelector: + {{- toYaml . | nindent 6 }} + {{ else -}} + nodeSelector: {} + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#toleration-v1-core + {{- with $config.tolerations }} + tolerations: + {{- toYaml . | nindent 6 }} + {{- else }} + tolerations: [] + # - effect: NoSchedule | PreferNoSchedule | NoExecute + # key: "" + # operator: Exists | Equal + # tolerationSeconds: 600 + # value: "" + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#affinity-v1-core + {{- with $config.affinity }} + affinity: + {{- toYaml . | nindent 6 }} + {{- else }} + affinity: {} + {{- end }} +{{ end }} +{{- else }} +jobs: {} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/chart/values-workers.part.tmpl b/pkg/generate/_templates/chart/values-workers.part.tmpl new file mode 100644 index 00000000..7a5e9974 --- /dev/null +++ b/pkg/generate/_templates/chart/values-workers.part.tmpl @@ -0,0 +1,220 @@ +{{- define "workers" }} + +{{- $kubeVersion := "v1.30" }} + +{{- with .workers }} +workers: +{{- range $name, $config := . }} + {{ $name }}: + paused: true + replicaCount: {{ $config.replicaCount | default 1 }} + image: + registry: {{ $config.image.registry | default $.docker.registry | default ("" | quote) }} + repository: {{ $config.image.repository | default $.projectPath }} + pullPolicy: {{ $config.image.pullPolicy | default ("" | quote) }} + # Overrides the image tag whose default is the chart appVersion. + tag: {{ $config.image.tag | default "" | quote }} + env: + {{- $env := merge (dict "BINARY_NAME" $name) (dict "BINARY_PORT" ($.docker.port | default 3000)) $config.env }} + {{- toYaml $env | nindent 6 }} + {{- with $config.envFrom }} + envFrom: + {{- toYaml . | nindent 6 }} + {{- else }} + envFrom: [] + # - prefix: "" + # configMapRef: + # name: "" + # secretRef: + # name: "" + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#probe-v1-core + {{ with $config.livenessProbe -}} + livenessProbe: + {{- toYaml . | nindent 6 }} + {{ else -}} + livenessProbe: false + # httpGet: + # httpHeaders: + # header-name: value + # path: /ping + # port: 3000 + # scheme: http + # initialDelaySeconds: 15 + # periodSeconds: 10 + # successThreshold: 1 + # failureThreshold: 3 + {{- end }} + {{- with $config.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 6 }} + {{- else }} + readinessProbe: false + # exec: + # command: ["ls", "-lart"] + # initialDelaySeconds: 15 + # periodSeconds: 10 + # successThreshold: 1 + # failureThreshold: 3 + {{- end }} + {{- with $config.startupProbe }} + startupProbe: + {{- toYaml . | nindent 6 }} + {{- else }} + startupProbe: false + # grpc: + # port: 3000 + # service: "" + # initialDelaySeconds: 15 + # periodSeconds: 10 + # successThreshold: 1 + # failureThreshold: 3 + {{- end }} + resources: + limits: + cpu: {{ $config.resources.limits.cpu | default "250m" }} + memory: {{ $config.resources.limits.memory | default "256Mi" }} + storage: {{ $config.resources.limits.storage | default "10Gi" }} + requests: + cpu: {{ $config.resources.requests.cpu | default "50m" }} + memory: {{ $config.resources.requests.memory | default "128Mi" }} + storage: {{ $config.resources.requests.storage | default "5Gi" }} + autoscaling: + enabled: {{ $config.autoscaling.enabled | default "false" }} + minReplicas: {{ $config.autoscaling.minReplicas | default 1 }} + maxReplicas: {{ $config.autoscaling.maxReplicas | default 10 }} + {{- with $config.autoscaling.metrics }} + metrics: + {{- toYaml . | nindent 8 }} + {{- else }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 80 + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 + {{- end }} + restartPolicy: {{ $config.restartPolicy | default "Always" }} + {{- with $config.configMap }} + configMap: + {{- toYaml . | nindent 6 }} + {{- else }} + configMap: {} + # mountPath: /etc/config/ + # tpl_folders: # folders to be included in configmap with tpl + # - folder_name + # include_folders: # folders to be included in configmap without tpl + # - folder_name + # data: + # name: value + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#volume-v1-core + {{- with $config.volumes }} + volumes: + {{- toYaml . | nindent 6 }} + {{- else }} + volumes: [] + # - name: "" + # configMap: + # name: configMapName + # - name: "" + # emptyDir: + # medium: "" + # sizeLimit: 1Gi + # - name: "" + # persistentVolumeClaim: + # claimName: "" + # readOnly: false + # - name: "" + # secret: + # secretName: "" + {{- end }} + {{- with $config.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 6 }} + {{- else }} + volumeMounts: [] + # - mountPath: /etc/config/ + # name: volume[*].name + # readOnly: true + {{- end }} + + {{ with $config.podAnnotations -}} + podAnnotations: + {{- toYaml . | nindent 6 }} + {{ else -}} + podAnnotations: {} + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#podsecuritycontext-v1-core + {{- with $config.podSecurityContext }} + podSecurityContext: + {{- toYaml . | nindent 6 }} + {{- else }} + podSecurityContext: {} + {{- end }} + # fsGroup: 2 + # fsGroupChangePolicy: Always | OnRootMismatch + # runAsGroup: 1001 + # runAsNonRoot: true + # runAsUser: 1001 + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#securitycontext-v1-core + {{- with $config.securityContext }} + securityContext: + {{- toYaml . | nindent 6 }} + {{- else }} + securityContext: {} + # allowPrivilegeEscalation: false + # capabilities: + # add: [] + # drop: [] + # privileged: false + # readOnlyRootFilesystem: true + # runAsGroup: 1001 + # runAsNonRoot: true + # runAsUser: 1001 + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#nodeselector-v1-core + {{ with $config.nodeSelector -}} + nodeSelector: + {{- toYaml . | nindent 6 }} + {{ else -}} + nodeSelector: {} + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#toleration-v1-core + {{- with $config.tolerations }} + tolerations: + {{- toYaml . | nindent 6 }} + {{- else }} + tolerations: [] + # - effect: NoSchedule | PreferNoSchedule | NoExecute + # key: "" + # operator: Exists | Equal + # tolerationSeconds: 600 + # value: "" + {{- end }} + + # https://kubernetes.io/docs/reference/generated/kubernetes-api/{{ $kubeVersion }}/#affinity-v1-core + {{- with $config.affinity }} + affinity: + {{- toYaml . | nindent 6 }} + {{- else }} + affinity: {} + {{- end }} +{{ end }} +{{- else }} +workers: {} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/values.yaml b/pkg/generate/_templates/chart/values.yaml.tmpl similarity index 51% rename from testdata/helm/success_dependencies/chart/values.yaml rename to pkg/generate/_templates/chart/values.yaml.tmpl index a2dab061..0419ef91 100644 --- a/testdata/helm/success_dependencies/chart/values.yaml +++ b/pkg/generate/_templates/chart/values.yaml.tmpl @@ -1,39 +1,55 @@ # Code generated by craft; DO NOT EDIT. +{{- $chart := get .Languages "helm" }} +{{- $maintainer := index $chart.maintainers 0 }} + +{{ with $chart.imagePullSecrets }} +imagePullSecrets: + {{- toYaml . | nindent 2 }} +{{ else -}} imagePullSecrets: [] +{{- end }} -nameOverride: "" -fullnameOverride: "" +nameOverride: {{ $chart.nameOverride | default ("" | quote) }} +fullnameOverride: {{ $chart.fullnameOverride | default ("" | quote) }} serviceAccount: # Specifies whether a service account should be created - create: false + create: {{ $chart.serviceAccount.create | default "false" }} # Annotations to add to the service account + {{- with $chart.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- else }} annotations: {} + {{- end }} # The name of the service account to use. # If not set and create is true, a name is generated using the fullname template - name: "" + name: {{ $chart.serviceAccount.name | default ("" | quote) }} ############################################# # all cronjobs # ############################################# -crons: {} +{{- template "cronjobs" $chart }} ############################################# # all jobs # ############################################# -jobs: {} +{{- template "jobs" $chart }} ############################################# # all workers # ############################################# -workers: {} +{{- template "workers" $chart }} ############################################# # all dependencies # ############################################# -dependency-name: - key: value - key_with_sub_keys: - key: value -second-dependency-name: {} \ No newline at end of file +{{- range $chart.dependencies }} +{{- if .values }} +{{ .name }}: + {{- toYaml .values | nindent 2 }} +{{- else }} +{{ .name }}: {} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/launcher.sh.tmpl b/pkg/generate/_templates/launcher.sh.tmpl new file mode 100644 index 00000000..97b2a8ad --- /dev/null +++ b/pkg/generate/_templates/launcher.sh.tmpl @@ -0,0 +1,13 @@ +#!/bin/sh +# Code generated by craft; DO NOT EDIT. + +case $BINARY_NAME in + +{{- $binaries := dict }} +{{- $_ := map $binaries .Clis .Crons .Jobs .Workers }} + +{{- range $name, $config := $binaries }} + {{ $name }}) /app/{{ $name }};; +{{- end }} + *) echo "invalid binary '$BINARY_NAME'" && exit 1;; +esac \ No newline at end of file diff --git a/pkg/generate/templates/renovate.json5.tmpl b/pkg/generate/_templates/renovate.json5.tmpl similarity index 81% rename from pkg/generate/templates/renovate.json5.tmpl rename to pkg/generate/_templates/renovate.json5.tmpl index a1d5cc36..a4d85e33 100644 --- a/pkg/generate/templates/renovate.json5.tmpl +++ b/pkg/generate/_templates/renovate.json5.tmpl @@ -2,7 +2,13 @@ // https://docs.renovatebot.com/configuration-options/ -<<- $categories := list "cd" "ci" "docker" "golang" "helm" "java" "js" "kubernetes" "python" "rust" >> +<<- $categories := list "cd" "ci" >> +<<- if or (hasKey .Languages "golang") (hasKey .Languages "hugo") >><<- $categories = append $categories "golang" >><<- end >> +<<- if hasKey .Languages "node" >><<- $categories = append $categories "js" >><<- end >> +<<- if hasKey .Languages "python" >><<- $categories = append $categories "python" >><<- end >> +<<- if hasKey .Languages "rust" >><<- $categories = append $categories "rust" >><<- end >> +<<- if not .NoChart >><<- $categories = concat $categories (list "helm" "kubernetes") >><<- end >> +<<- if .Docker >><<- $categories = append $categories "docker" >><<- end >> { "extends": [ ":gitSignOff" ], diff --git a/testdata/golang/success_binary_cron/scripts/build.mk b/pkg/generate/_templates/scripts/build-golang.part.tmpl similarity index 66% rename from testdata/golang/success_binary_cron/scripts/build.mk rename to pkg/generate/_templates/scripts/build-golang.part.tmpl index d0ce6955..467d8266 100644 --- a/testdata/golang/success_binary_cron/scripts/build.mk +++ b/pkg/generate/_templates/scripts/build-golang.part.tmpl @@ -1,5 +1,4 @@ -# Code generated by craft; DO NOT EDIT. - +{{- define "golang" }} GCI_CONFIG_PATH := .golangci.yml .PHONY: reports @@ -28,17 +27,27 @@ test-race: test-cover: reports @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s +{{- $binaries := dict }} +{{- $_ := map $binaries .Clis .Crons .Jobs .Workers }} + +{{- if gt .Binaries 0 }} + .PHONY: buildall -buildall: build-cron-name +buildall:{{ range $name, $config := $binaries }} build-{{ $name }}{{ end }} -.PHONY: cron-name +.PHONY:{{ range $name, $config := $binaries }} {{ $name }}{{ end }} build-%: @CGO_ENABLED=0 go build -o $* cmd/$*/main.go -.PHONY: cron-name +.PHONY:{{ range $name, $config := $binaries }} {{ $name }}{{ end }} local-%: @go run cmd/$*/main.go +{{- end }} + +{{- if .Docker }} .PHONY: build-docker build-docker: - @docker build -t craft . \ No newline at end of file + @docker build -t {{ .ProjectName }} . +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/lang_hugo/scripts/build.mk.tmpl b/pkg/generate/_templates/scripts/build-hugo.part.tmpl similarity index 78% rename from pkg/generate/templates/lang_hugo/scripts/build.mk.tmpl rename to pkg/generate/_templates/scripts/build-hugo.part.tmpl index e50af4c0..a35fea9a 100644 --- a/pkg/generate/templates/lang_hugo/scripts/build.mk.tmpl +++ b/pkg/generate/_templates/scripts/build-hugo.part.tmpl @@ -1,4 +1,4 @@ -# Code generated by craft; DO NOT EDIT. +{{- define "hugo" }} .PHONY: build build: @@ -9,14 +9,15 @@ serve: @hugo server --disableFastRender .PHONY: production -<<- if .IsStatic "netlify" >> +{{- if .IsStatic "netlify" }} production: @netlify dev -c "make serve" \ --target-port 1313 --port 8888 --dir dist --framework hugo --context production -<<- else >> +{{- else }} production: build @python3 -m http.server --directory dist -<<- end >> \ No newline at end of file +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/scripts/build.mk.tmpl b/pkg/generate/_templates/scripts/build.mk.tmpl new file mode 100644 index 00000000..be9ee15d --- /dev/null +++ b/pkg/generate/_templates/scripts/build.mk.tmpl @@ -0,0 +1,4 @@ +# Code generated by craft; DO NOT EDIT. + +{{- if hasKey .Languages "hugo" }}{{ template "hugo" . }}{{- end }} +{{- if hasKey .Languages "golang" }}{{ template "golang" . }}{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/scripts/craft.mk.tmpl b/pkg/generate/_templates/scripts/craft.mk.tmpl similarity index 75% rename from pkg/generate/templates/scripts/craft.mk.tmpl rename to pkg/generate/_templates/scripts/craft.mk.tmpl index 07e49740..a549d77d 100644 --- a/pkg/generate/templates/scripts/craft.mk.tmpl +++ b/pkg/generate/_templates/scripts/craft.mk.tmpl @@ -6,7 +6,7 @@ generate: .PHONY: clean clean: -<<- if hasKey .Languages "golang" >> +{{- if hasKey .Languages "golang" }} @go clean -<<- end >> +{{- end }} @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_binary_cron/scripts/install.mk b/pkg/generate/_templates/scripts/install-golang.part.tmpl similarity index 94% rename from testdata/golang/success_binary_cron/scripts/install.mk rename to pkg/generate/_templates/scripts/install-golang.part.tmpl index a7835b56..c5770c84 100644 --- a/testdata/golang/success_binary_cron/scripts/install.mk +++ b/pkg/generate/_templates/scripts/install-golang.part.tmpl @@ -1,4 +1,4 @@ -# Code generated by craft; DO NOT EDIT. +{{- define "golang" }} .PHONY: install-golangci-lint install-golangci-lint: @@ -23,6 +23,8 @@ endef install-go: ; @$(value install_go) .ONESHELL: +{{- if .Docker }} + define install_docker if which docker >/dev/null; then echo "docker already installed" @@ -35,4 +37,6 @@ dockerd-rootless-setuptool.sh install endef .PHONY: install-docker install-docker: ; @$(value install_docker) -.ONESHELL: \ No newline at end of file +.ONESHELL: +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/templates/lang_hugo/scripts/install.mk.tmpl b/pkg/generate/_templates/scripts/install-hugo.part.tmpl similarity index 93% rename from pkg/generate/templates/lang_hugo/scripts/install.mk.tmpl rename to pkg/generate/_templates/scripts/install-hugo.part.tmpl index 11e0da14..7af6522e 100644 --- a/pkg/generate/templates/lang_hugo/scripts/install.mk.tmpl +++ b/pkg/generate/_templates/scripts/install-hugo.part.tmpl @@ -1,4 +1,4 @@ -# Code generated by craft; DO NOT EDIT. +{{- define "hugo" }} define install_hugo current_version=$(hugo version || echo "hugo v0.0.0") @@ -17,7 +17,7 @@ endef install-hugo: ; @$(value install_hugo) .ONESHELL: -<<- if .IsStatic "netlify" >> +{{- if .IsStatic "netlify" }} define install_netlify if which netlify >/dev/null; then @@ -36,4 +36,5 @@ endef .PHONY: install-netlify install-netlify: ; @$(value install_netlify) .ONESHELL: -<<- end >> \ No newline at end of file +{{- end }} +{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/scripts/install.mk.tmpl b/pkg/generate/_templates/scripts/install.mk.tmpl new file mode 100644 index 00000000..be9ee15d --- /dev/null +++ b/pkg/generate/_templates/scripts/install.mk.tmpl @@ -0,0 +1,4 @@ +# Code generated by craft; DO NOT EDIT. + +{{- if hasKey .Languages "hugo" }}{{ template "hugo" . }}{{- end }} +{{- if hasKey .Languages "golang" }}{{ template "golang" . }}{{- end }} \ No newline at end of file diff --git a/pkg/generate/_templates/sonar.properties.tmpl b/pkg/generate/_templates/sonar.properties.tmpl new file mode 100644 index 00000000..55d89d74 --- /dev/null +++ b/pkg/generate/_templates/sonar.properties.tmpl @@ -0,0 +1,44 @@ +# Code generated by craft; DO NOT EDIT. + +sonar.host.url=https://sonarcloud.io +sonar.qualitygate.wait=true + +{{- $maintainer := index .Maintainers 0 }} + +sonar.organization={{ $maintainer.Name }} +sonar.projectBaseDir=. +sonar.projectKey={{ .ProjectPath | replace "/" "_" }} +sonar.projectName={{ .ProjectName }} + +{{- $exclusions := list }} +{{- $inclusions := list }} + +{{- if hasKey .Languages "golang" }} +{{- $exclusions = concat $exclusions (list "**/examples/**" "**/testdata/**" "**/vendor/**") }} +{{- $inclusions = append $inclusions "**/*_test.go" }} +{{- end }} + +{{- if hasKey .Languages "node" }} +{{- $exclusions = concat $exclusions (list "node_modules/**" "dist/**" "**/*.spec.js" "**/*.spec.ts" "**/*.test.js" "**/*.test.ts") }} +{{- $inclusions = concat $inclusions (list "**/*.spec.js" "**/*.spec.ts" "**/*.test.js" "**/*.test.ts") }} +{{- end }} + +sonar.exclusions={{ join "," $exclusions }} +sonar.test.inclusions={{ join "," $inclusions }} + +{{- if hasKey .Languages "golang" }} +sonar.coverage.exclusions=cmd/**,**/cobra/**,**/tests/**,**/testutils/** +{{- if eq .CI.Name "gitlab" }} + +sonar.go.tests.reportPaths=reports/go-test.native.json +{{- end }} +sonar.go.coverage.reportPaths=reports/go-coverage.native.out +sonar.go.golangci-lint.reportPaths=reports/go-ci-lint.checkstyle.xml +{{- end }} + +{{- if hasKey .Languages "node" }} + +sonar.testExecutionReportPaths=reports/node-test.sonar.xml +sonar.eslint.reportPaths=reports/node-lint.xslint.json +sonar.javascript.lcov.reportPaths=reports/lcov.info +{{- end }} \ No newline at end of file diff --git a/pkg/generate/doc.go b/pkg/generate/doc.go index 338e08c9..eb834779 100644 --- a/pkg/generate/doc.go +++ b/pkg/generate/doc.go @@ -1,46 +1 @@ -/* -The generate package provides multiple functions to extend craft generation. - -The main function to be used is Run and it can be tuned with options (see documentation). - -Multiple Run option are available to further tune the generation of a project with craft: WithMetaHandlers, WithDelimiters, WithDetects, WithDestination, WithForce, WithForceAll, WithLogger, WithTemplates. -For further information about those options, please consult their specific documentation. - -The best options for generation tuning are however WithMetaHandlers, WithDetects, WithTemplates. -Those three options allows to override default craft templates, enrich generated files conditions and even add new languages parsing and generation. - -Example: - - func main() { - ctx := context.Background() - config := craft.Configuration{} // may be read and saved with craft package - - generate.SetLogger(clog.Std()) // set stdlib log, clog.Slog() can also be used or even a custom implement of clog.Logger interface - - config, err := generate.Run(ctx, config, - generate.WithDelimiters("<<", ">>"), - generate.WithDestination(destdir), - - // Detects returns the default slice of DetectFuncs - generate.WithDetectFuncs(generate.Detects()...), - - // MetaHandlers returns the default slice of MetaHandlers - // which is a slice of funcs each taking as input Metadata and returning a func handling a specific file - // i.e. the default ones are related to Docker, GitHub Actions, GitLab CI/CD, goreleaser, Makefile and Sonar - generate.WithMetaHandlers(generate.MetaHandlers()...), - - generate.WithForce(force...), - generate.WithForceAll(forceAll), - - // override the templates, by default here FS is the embedded fs of craft which default templates - // another possibility is cfs.OS which takes an implementation reading the current filesystem - // - // the first input string it the folder path where the templates are located - generate.WithTemplates("templates", generate.FS()), - ) - if err != nil { - // handle err - } - } -*/ package generate diff --git a/pkg/generate/filehandler.go b/pkg/generate/filehandler.go deleted file mode 100644 index 9d5fe04d..00000000 --- a/pkg/generate/filehandler.go +++ /dev/null @@ -1,233 +0,0 @@ -package generate - -import ( - "path" - "regexp" - "slices" - "strings" - - "github.com/kilianpaquier/craft/pkg/craft" -) - -// FileHandler represents a function to be executed on a specific file (with its source, destination and name). -// -// It returns two booleans, the first one to indicate that the FileHandler is the right one for the inputs. -// The second one to indicate whether to apply something or not (apply something means doing whatever execution on the file). -// -// FileHandler is specifically used for optional handlers (to indicate whether to generate or remove optional files in craft generation). -type FileHandler func(src, dest, name string) (ok bool, apply bool) - -// MetaHandler is the signature function returning a FileHandler when invoked with Metadata. -type MetaHandler func(metadata Metadata) FileHandler - -// MetaHandlers returns the full slice of default file handlers (files being optionally generated depending on craft configuration and parsed languages). -func MetaHandlers() []MetaHandler { - // order is important since the first ok return will not execute the next ones - return []MetaHandler{ - BotsHandler, - DockerHandler, - GitHubHandler, - GitLabHandler, - GoreleaserHandler, - MkHandler, - ReadmeHandler, - ReleasercHandler, - SonarHandler, - } -} - -// BotsHandler returns the handler for dependabot and renovate maintenance bots optional generation. -func BotsHandler(metadata Metadata) FileHandler { - return func(_, _, name string) (_ bool, _ bool) { - switch name { - case "dependabot.yml": - return true, metadata.Platform == craft.GitHub && metadata.IsBot(craft.Dependabot) - case "renovate.json5": - return true, metadata.IsBot(craft.Renovate) - } - return false, false - } -} - -// DockerHandler returns the handler for docker option generation matching. -func DockerHandler(metadata Metadata) FileHandler { - return func(_, _, name string) (_ bool, _ bool) { - if slices.Contains([]string{"Dockerfile", ".dockerignore"}, name) { - return true, metadata.Docker != nil && metadata.Binaries > 0 - } - if name == "launcher.sh" { - return true, metadata.Docker != nil && metadata.Binaries > 1 - } - return false, false - } -} - -// GitHubHandler returns the handler for github option generation matching. -func GitHubHandler(metadata Metadata) FileHandler { - ga := githubActionsHandler(metadata) - gc := githubConfigHandler(metadata) - gw := githubWorkflowsHandler(metadata) - - return func(src, dest, name string) (_ bool, _ bool) { - if name == ".codecov.yml" { - return true, len(metadata.Languages) > 0 && metadata.IsCI(craft.GitHub) && slices.Contains(metadata.CI.Options, craft.CodeCov) - } - - // files related to dir .github/workflows - if ok, apply := gw(src, dest, name); ok { - return true, apply - } - - // files related to dir .github/actions - if ok, apply := ga(src, dest, name); ok { - return true, apply - } - - // files related to dir .github - if ok, apply := gc(src, dest, name); ok { - return true, apply - } - - return false, false - } -} - -// githubConfigHandler returns the handler related to files in .github folder (github platform configuration files). -func githubConfigHandler(metadata Metadata) FileHandler { - return func(src, _, name string) (_ bool, _ bool) { - // files related to dir .github - if !strings.Contains(src, path.Join(".github", name)) { - return false, false - } - - switch name { - case "release.yml": - // useful to sometimes make manual releases (since it's a github configuration and not something specific to an action) - return true, metadata.Platform == craft.GitHub - case "labeler.yml": - return true, metadata.IsCI(craft.GitHub) && slices.Contains(metadata.CI.Options, craft.Labeler) - } - return true, metadata.Platform == craft.GitHub - } -} - -// githubWorkflowsHandler returns the handler related to files in .github/workflows (github actions files). -func githubWorkflowsHandler(metadata Metadata) FileHandler { //nolint:cyclop - return func(src, _, name string) (_ bool, _ bool) { - // files related to dir .github/workflows - if !strings.Contains(src, path.Join(".github", "workflows", name)) { - return false, false - } - - switch name { - case "build.yml": - if _, ok := metadata.Languages["golang"]; ok { - return true, !metadata.NoGoreleaser && len(metadata.Clis) > 0 && metadata.IsCI(craft.GitHub) - } - case "codeql.yml": - return true, len(metadata.Languages) > 0 && metadata.IsCI(craft.GitHub) && slices.Contains(metadata.CI.Options, craft.CodeQL) - case "docker.yml": - return true, metadata.Docker != nil && metadata.Binaries > 0 && metadata.IsCI(craft.GitHub) - case "netlify.yml": - return true, metadata.IsCI(craft.GitHub) && metadata.IsStatic(craft.Netlify) - case "pages.yml": - return true, metadata.IsCI(craft.GitHub) && metadata.IsStatic(craft.Pages) - case "release.yml": - return true, metadata.IsCI(craft.GitHub) && metadata.CI.Release != nil //nolint:revive - case "renovate.yml": - return true, metadata.IsBot(craft.Renovate) && metadata.CI != nil && metadata.CI.Auth.Maintenance != nil && *metadata.CI.Auth.Maintenance != craft.Mendio //nolint:revive - case "labeler.yml": - return true, metadata.IsCI(craft.GitHub) && slices.Contains(metadata.CI.Options, craft.Labeler) - } - return true, metadata.IsCI(craft.GitHub) - } -} - -var githubActionFileRegexp = regexp.MustCompile(`\.github/actions/[\w]+/action\.yml\.tmpl$`) - -// githubActionsHandler returns the handler for all files related to .github/actions directory. -func githubActionsHandler(metadata Metadata) FileHandler { - return func(src, _, _ string) (_ bool, _ bool) { - // files related to dir .github/actions - if !githubActionFileRegexp.MatchString(src) { - return false, false - } - - if strings.Contains(src, path.Join(".github", "actions", "version")) { - return true, metadata.IsCI(craft.GitHub) && (metadata.Docker != nil || metadata.HasRelease()) - } - return true, metadata.IsCI(craft.GitHub) - } -} - -// GitLabHandler returns the handler for gitlab option generation matching. -func GitLabHandler(metadata Metadata) FileHandler { - return func(src, _, name string) (_ bool, _ bool) { - // files related to dir .gitlab/workflows - if strings.Contains(src, path.Join(".gitlab", "workflows", name)) { - return true, metadata.IsCI(craft.GitLab) - } - - // files related to dir .gitlab - if strings.Contains(src, path.Join(".gitlab", name)) { - if name == "semrel-plugins.txt" { - return true, metadata.IsCI(craft.GitLab) - } - return true, metadata.Platform == craft.GitLab // keep early return in case some specify behavior on files occur - } - - // root files related to gitlab - if name == ".gitlab-ci.yml" { - return true, metadata.IsCI(craft.GitLab) - } - return false, false - } -} - -// GoreleaserHandler returns the handler for goreleaser option generation matching. -func GoreleaserHandler(metadata Metadata) FileHandler { - return func(_, _, name string) (_ bool, _ bool) { - if name != ".goreleaser.yml" { - return false, false - } - return true, !metadata.NoGoreleaser && len(metadata.Clis) > 0 - } -} - -// MkHandler returns the handler for makefile option generation matching. -func MkHandler(metadata Metadata) FileHandler { - return func(_, _, name string) (_ bool, _ bool) { - return name == "Makefile" || strings.HasSuffix(name, ".mk"), !metadata.NoMakefile - } -} - -// ReadmeHandler returns the handler for README.md option generation matching. -func ReadmeHandler(metadata Metadata) FileHandler { - return func(_, _, name string) (ok bool, apply bool) { - if name != "README.md" { - return false, false - } - return true, !metadata.NoReadme - } -} - -// ReleasercHandler returns the handler for releaserc option generation matching. -func ReleasercHandler(metadata Metadata) FileHandler { - return func(_, _, name string) (_ bool, _ bool) { - if name != ".releaserc.yml" { - return false, false - } - return true, metadata.HasRelease() - } -} - -// SonarHandler returns the handler for sonar option generation matching. -func SonarHandler(metadata Metadata) FileHandler { - hasSonar := metadata.CI != nil && slices.Contains(metadata.CI.Options, craft.Sonar) - return func(_, _, name string) (_ bool, _ bool) { - if name != "sonar.properties" { - return false, false - } - return true, len(metadata.Languages) > 0 && hasSonar - } -} diff --git a/pkg/generate/fsys.go b/pkg/generate/fsys.go deleted file mode 100644 index 41eb032e..00000000 --- a/pkg/generate/fsys.go +++ /dev/null @@ -1,155 +0,0 @@ -package generate - -import ( - "context" - "errors" - "fmt" - "io/fs" - "os" - "path" - "path/filepath" - "slices" - "strings" - "text/template" - - "github.com/Masterminds/sprig/v3" - "github.com/kilianpaquier/cli-sdk/pkg/cfs" - "github.com/kilianpaquier/craft/pkg/craft" - "github.com/kilianpaquier/craft/pkg/templating" -) - -var ( - errDelete = errors.New("file deletion") - errExist = errors.New("file already exists") -) - -// generated is the string for generated files. -const generated = "Code generated by craft; DO NOT EDIT." - -// IsGenerated returns truthy if input destination is a generated file. -func IsGenerated(dest string) bool { - // retrieve file content, if there's an error, generation to make - content, err := os.ReadFile(dest) - if err != nil { - return true - } - - // special case (shouldn't happen) where the destination has been replaced with an empty file - if len(content) == 0 { - return true - } - lines := strings.Split(string(content), "\n") - - // check first line for generated regexp - if len(lines) >= 1 && strings.Contains(lines[0], generated) { - return true - } - - // check second line for generated regexp - if len(lines) >= 2 && strings.Contains(lines[1], generated) { - return true - } - return false -} - -// BasicExecFunc is a simplified function returning a basic ExecFunc for an input template folder name. -func BasicExecFunc(name string) ExecFunc { - return func(_ context.Context, fsys cfs.FS, srcdir, destdir string, metadata Metadata, opts ExecOpts) error { - return handleDir(fsys, srcdir, destdir, metadata, name, opts) - } -} - -// handleDir walks over input srcdir and apply template of every src entry into destdir. -func handleDir(fsys cfs.FS, srcdir, destdir string, data any, name string, opts ExecOpts) error { - // read source directory - entries, err := fsys.ReadDir(srcdir) - if err != nil { - return fmt.Errorf("read directory: %w", err) - } - - errs := make([]error, 0, len(entries)) - for _, entry := range entries { - src := path.Join(srcdir, entry.Name()) - dest := filepath.Join(destdir, entry.Name()) - - if entry.IsDir() { - // apply generation at root if the folder name is the dir generate name - if entry.Name() == name { - errs = append(errs, handleDir(fsys, src, destdir, data, name, opts)) - continue - } - - // apply templates on subdirs not being the reserved ones for languages - if !strings.HasPrefix(entry.Name(), "lang_") { - errs = append(errs, handleDir(fsys, src, dest, data, name, opts)) - continue - } - continue - } - - // don't template files without .tmpl extension - if !strings.HasSuffix(src, craft.TmplExtension) { - continue - } - dest = strings.TrimSuffix(dest, craft.TmplExtension) - - if err := handleFile(fsys, src, dest, data, opts); err != nil { - if errors.Is(err, errDelete) { - log.Warnf("failed to delete '%s': %s", entry.Name(), err.Error()) - continue - } - if errors.Is(err, errExist) { - log.Infof("not copying '%s' since it already exists", filepath.Base(dest)) - continue - } - errs = append(errs, err) - } - } - return errors.Join(errs...) -} - -// handleFile is a private function used to handle a specific file entry -// during iterative loops over folders and subfolders. -func handleFile(fsys cfs.FS, src, dest string, data any, opts ExecOpts) error { - filename := filepath.Base(dest) - - // verify that file matches generation rules - generate := opts.ForceAll || IsGenerated(dest) || slices.Contains(opts.Force, filename) - singleGeneration := filename == craft.File && cfs.Exists(dest) - if !generate || singleGeneration { - return errExist - } - - // check if filename matches an optional file - for _, handler := range opts.FileHandlers { - ok, apply := handler(src, dest, filename) - if !ok { - // don't do anything since the handler is not the right one for this file - continue - } - if apply { - // break loop since optional file was found - break - } - - // handle optional file deletion - if err := os.RemoveAll(dest); err != nil && !errors.Is(err, fs.ErrNotExist) { - return fmt.Errorf("remove file '%s': %w: %w", filename, errDelete, err) - } - return nil - } - - tmpl, err := template.New(filepath.Base(src)). - Funcs(sprig.FuncMap()). - Funcs(templating.FuncMap()). - Delims(opts.StartDelim, opts.EndDelim). - ParseFS(fsys, src) - if err != nil { - return fmt.Errorf("parse template file: %w", err) - } - - if err := templating.Execute(tmpl, data, dest); err != nil { - return fmt.Errorf("template execute: %w", err) - } - return nil -} diff --git a/pkg/generate/fsys_test.go b/pkg/generate/fsys_test.go deleted file mode 100644 index 6fce136a..00000000 --- a/pkg/generate/fsys_test.go +++ /dev/null @@ -1,742 +0,0 @@ -package generate_test - -import ( - "context" - "fmt" - "os" - "path" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/kilianpaquier/cli-sdk/pkg/cfs" - testfs "github.com/kilianpaquier/cli-sdk/pkg/cfs/tests" - "github.com/kilianpaquier/craft/internal/helpers" - "github.com/kilianpaquier/craft/pkg/craft" - "github.com/kilianpaquier/craft/pkg/generate" -) - -func TestIsGenerated(t *testing.T) { - t.Run("generated_doesnt_exist", func(t *testing.T) { - // Arrange - dest := filepath.Join(t.TempDir(), "invalid.txt") - - // Act - generated := generate.IsGenerated(dest) - - // Assert - assert.True(t, generated) - }) - - t.Run("not_generated_file", func(t *testing.T) { - // Arrange - dest := filepath.Join(t.TempDir(), "file.txt") - err := os.WriteFile(dest, []byte("not generated"), cfs.RwRR) - require.NoError(t, err) - - // Act - generated := generate.IsGenerated(dest) - - // Assert - assert.False(t, generated) - }) - - t.Run("generated_folder", func(t *testing.T) { - // Arrange - dest := filepath.Join(t.TempDir(), "folder") - require.NoError(t, os.Mkdir(dest, cfs.RwxRxRxRx)) - - // Act - generated := generate.IsGenerated(dest) - - // Assert - assert.True(t, generated) - }) - - t.Run("generated_no_lines", func(t *testing.T) { - // Arrange - dest := filepath.Join(t.TempDir(), "file.txt") - file, err := os.Create(dest) - require.NoError(t, err) - t.Cleanup(func() { assert.NoError(t, file.Close()) }) - - // Act - generated := generate.IsGenerated(dest) - - // Assert - assert.True(t, generated) - }) - - t.Run("generated_first_line", func(t *testing.T) { - // Arrange - dest := filepath.Join(t.TempDir(), "file.txt") - err := os.WriteFile(dest, []byte("// Code generated by craft; DO NOT EDIT."), cfs.RwRR) - require.NoError(t, err) - - // Act - generated := generate.IsGenerated(dest) - - // Assert - assert.True(t, generated) - }) - - t.Run("generated_md_comment", func(t *testing.T) { - // Arrange - dest := filepath.Join(t.TempDir(), "file.txt") - err := os.WriteFile(dest, []byte(""), cfs.RwRR) - require.NoError(t, err) - - // Act - generated := generate.IsGenerated(dest) - - // Assert - assert.True(t, generated) - }) - - t.Run("generated_second_line", func(t *testing.T) { - // Arrange - dest := filepath.Join(t.TempDir(), "file.txt") - err := os.WriteFile(dest, []byte("\n# Code generated by craft; DO NOT EDIT."), cfs.RwRR) - require.NoError(t, err) - - // Act - generated := generate.IsGenerated(dest) - - // Assert - assert.True(t, generated) - }) - - t.Run("generated_json", func(t *testing.T) { - // Arrange - dest := filepath.Join(t.TempDir(), "file.txt") - err := os.WriteFile(dest, []byte(`{ - "//": "Code generated by craft; DO NOT EDIT.", - }`), cfs.RwRR) - require.NoError(t, err) - - // Act - generated := generate.IsGenerated(dest) - - // Assert - assert.True(t, generated) - }) -} - -func TestExec_Generic(t *testing.T) { - ctx := context.Background() - exec := generate.BasicExecFunc("lang_generic") - - setup := func(metadata generate.Metadata) generate.Metadata { - metadata.Maintainers = []*craft.Maintainer{{Name: "maintainer name"}} - metadata.ProjectHost = "example.com" - metadata.ProjectName = "craft" - metadata.ProjectPath = "kilianpaquier/craft" - return metadata - } - - verify := test(ctx, exec, "generic") - - t.Run("success_releases_github", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitHub, - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubToken)}, - Release: &craft.Release{Auto: true, Backmerge: true}, - }, - NoMakefile: true, - Platform: craft.GitHub, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - - t.Run("success_options", func(t *testing.T) { - for _, tc := range []string{craft.GitHub, craft.GitLab} { - t.Run("success_options_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: tc, - Options: craft.CIOptions(), - }, - NoMakefile: true, - Platform: tc, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - } - }) - - t.Run("success_release_gitlab", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitLab, - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubToken)}, - Release: &craft.Release{Auto: true, Backmerge: true}, - }, - NoMakefile: true, - Platform: craft.GitLab, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - - t.Run("success_bot_github", func(t *testing.T) { - for _, tc := range []string{craft.Dependabot, craft.Renovate} { - t.Run("success_bot_github_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - Bot: helpers.ToPtr(tc), - NoMakefile: true, - Platform: craft.GitHub, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - } - }) - - t.Run("success_bot_gitlab_renovate", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - Bot: helpers.ToPtr(craft.Renovate), - CI: &craft.CI{Name: craft.GitLab}, - NoMakefile: true, - Platform: craft.GitLab, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - - t.Run("success_makefile", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{NoMakefile: false}, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) -} - -func TestExec_Golang(t *testing.T) { - ctx := context.Background() - golang := generate.BasicExecFunc("lang_golang") - - setup := func(metadata generate.Metadata) generate.Metadata { - metadata.Languages = map[string]any{"golang": generate.Gomod{LangVersion: "1.22"}} - metadata.Maintainers = []*craft.Maintainer{{Name: "maintainer name"}} - metadata.ProjectHost = "example.com" - metadata.ProjectName = "craft" - metadata.ProjectPath = "kilianpaquier/craft" - return metadata - } - - verify := test(ctx, golang, "golang") - - t.Run("success_releases_github", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitHub, - Auth: craft.Auth{Release: helpers.ToPtr(craft.PersonalToken)}, - Release: &craft.Release{Backmerge: true}, - }, - NoMakefile: true, - Platform: craft.GitHub, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - - t.Run("success_options", func(t *testing.T) { - for _, tc := range []string{craft.GitHub, craft.GitLab} { - t.Run("success_options_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: tc, - Options: craft.CIOptions(), - }, - NoMakefile: true, - Platform: tc, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - } - }) - - t.Run("success_release_gitlab", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitLab, - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubToken)}, - Release: &craft.Release{Backmerge: true}, - }, - Platform: craft.GitLab, - }, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_bot_github", func(t *testing.T) { - for _, tc := range []string{craft.Dependabot, craft.Renovate} { - t.Run("success_bot_github_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - Bot: helpers.ToPtr(tc), - NoMakefile: true, - Platform: craft.GitHub, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - } - }) - - t.Run("success_binary_none", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{}) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_binary_cli", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Binaries: 1, - Clis: map[string]struct{}{"cli-name": {}}, - Configuration: craft.Configuration{ - Docker: &craft.Docker{}, - }, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_binary_cron", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Binaries: 1, - Configuration: craft.Configuration{ - Docker: &craft.Docker{}, - }, - Crons: map[string]struct{}{"cron-name": {}}, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_binary_job", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Binaries: 1, - Configuration: craft.Configuration{ - Docker: &craft.Docker{}, - }, - Jobs: map[string]struct{}{"job-name": {}}, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_binary_worker", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Binaries: 1, - Configuration: craft.Configuration{ - Docker: &craft.Docker{}, - }, - Workers: map[string]struct{}{"worker-name": {}}, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_binaries", func(t *testing.T) { - for _, tc := range []string{craft.GitHub, craft.GitLab} { - t.Run("success_binary_all_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Binaries: 4, - Clis: map[string]struct{}{"cli-name": {}}, - Configuration: craft.Configuration{ - CI: &craft.CI{Name: tc}, - Docker: &craft.Docker{Port: helpers.ToPtr(uint16(5000)), Registry: helpers.ToPtr("example.com")}, - License: helpers.ToPtr("mit"), - NoGoreleaser: false, - Platform: tc, - }, - Crons: map[string]struct{}{"cron-name": {}}, - Jobs: map[string]struct{}{"job-name": {}}, - Workers: map[string]struct{}{"worker-name": {}}, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - } - }) -} - -func TestExec_Hugo(t *testing.T) { - ctx := context.Background() - hugo := generate.BasicExecFunc("lang_hugo") - - setup := func(metadata generate.Metadata) generate.Metadata { - metadata.Languages = map[string]any{"hugo": generate.Gomod{LangVersion: "1.22"}} - metadata.Maintainers = []*craft.Maintainer{{Name: "maintainer name"}} - metadata.ProjectHost = "example.com" - metadata.ProjectName = "craft" - metadata.ProjectPath = "kilianpaquier/craft" - return metadata - } - - verify := test(ctx, hugo, "hugo") - - t.Run("success_releases_github", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitHub, - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubApp)}, - Release: &craft.Release{}, - }, - NoMakefile: true, - Platform: craft.GitHub, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - - t.Run("success_options", func(t *testing.T) { - for _, tc := range []string{craft.GitHub, craft.GitLab} { - t.Run("success_options_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: tc, - Options: craft.CIOptions(), - }, - NoMakefile: true, - Platform: tc, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - } - }) - - t.Run("success_release_gitlab", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitLab, - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubToken)}, - Release: &craft.Release{}, - }, - Platform: craft.GitLab, - }, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_bots_github", func(t *testing.T) { - for _, tc := range []string{craft.Dependabot, craft.Renovate} { - t.Run("success_bot_github_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - Bot: helpers.ToPtr(tc), - NoMakefile: true, - Platform: craft.GitHub, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - } - }) - - t.Run("success_statics", func(t *testing.T) { - cases := []struct { - CI string - Static craft.Static - }{ - {CI: craft.GitHub, Static: craft.Static{Name: craft.Netlify}}, - {CI: craft.GitHub, Static: craft.Static{Name: craft.Netlify, Auto: true}}, - {CI: craft.GitHub, Static: craft.Static{Name: craft.Pages}}, - {CI: craft.GitHub, Static: craft.Static{Name: craft.Pages, Auto: true}}, - {CI: craft.GitLab, Static: craft.Static{Name: craft.Netlify}}, - {CI: craft.GitLab, Static: craft.Static{Name: craft.Pages}}, - } - - for _, tc := range cases { - name := func() string { - if tc.Static.Auto { - return fmt.Sprintf("success_static_%s_auto_%s", tc.Static.Name, tc.CI) - } - return fmt.Sprintf("success_static_%s_%s", tc.Static.Name, tc.CI) - }() - t.Run(name, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: tc.CI, - Static: &tc.Static, - }, - Platform: tc.CI, - }, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - } - }) -} - -func TestExec_Nodejs(t *testing.T) { - ctx := context.Background() - nodejs := generate.BasicExecFunc("lang_nodejs") - - setup := func(metadata generate.Metadata) generate.Metadata { - metadata.Maintainers = []*craft.Maintainer{{Name: "maintainer name"}} - metadata.NoMakefile = true - metadata.ProjectHost = "example.com" - metadata.ProjectName = "craft" - metadata.ProjectPath = "kilianpaquier/craft" - return metadata - } - - verify := test(ctx, nodejs, "nodejs") - - t.Run("success_release_github", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitHub, - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubToken)}, - Release: &craft.Release{}, - }, - NoMakefile: true, - Platform: craft.GitHub, - }, - Languages: map[string]any{ - "nodejs": generate.PackageJSON{PackageManager: "bun@1.0.0"}, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - - t.Run("success_options", func(t *testing.T) { - for _, tc := range []string{craft.GitHub, craft.GitLab} { - t.Run("success_options_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: tc, - Options: craft.CIOptions(), - }, - NoMakefile: true, - Platform: tc, - }, - Languages: map[string]any{ - "nodejs": generate.PackageJSON{PackageManager: "pnpm@9.0.0"}, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - } - }) - - t.Run("success_release_gitlab", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: craft.GitLab, - Auth: craft.Auth{Release: helpers.ToPtr(craft.GitHubToken)}, - Release: &craft.Release{}, - }, - Platform: craft.GitLab, - }, - Languages: map[string]any{ - "nodejs": generate.PackageJSON{PackageManager: "pnpm@9.0.0"}, - }, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_bots_github", func(t *testing.T) { - for _, tc := range []string{craft.Dependabot, craft.Renovate} { - t.Run("success_both_github_"+tc, func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - Bot: helpers.ToPtr(tc), - NoMakefile: true, - Platform: craft.GitHub, - }, - Languages: map[string]any{ - "nodejs": generate.PackageJSON{PackageManager: "yarn@2.4.3"}, - }, - }) - destdir := t.TempDir() - - // Act & Asset - verify(t, destdir, metadata) - }) - } - }) - - t.Run("success_statics", func(t *testing.T) { - cases := []struct { - CI string - Static string - }{ - {CI: craft.GitHub, Static: craft.Netlify}, - {CI: craft.GitHub, Static: craft.Pages}, - {CI: craft.GitLab, Static: craft.Netlify}, - {CI: craft.GitLab, Static: craft.Pages}, - } - - for _, tc := range cases { - t.Run(fmt.Sprintf("success_static_%s_%s", tc.Static, tc.CI), func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{ - Name: tc.CI, - Static: &craft.Static{Name: tc.Static}, - }, - Platform: tc.CI, - }, - Languages: map[string]any{ - "nodejs": generate.PackageJSON{Main: helpers.ToPtr("index.js"), PackageManager: "bun@1.0.0"}, - }, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - } - }) -} - -// test returns the verify function for every generation verification to do. -func test(ctx context.Context, exec generate.ExecFunc, name string) func(t *testing.T, destdir string, metadata generate.Metadata) { - srcdir := "templates" - assertdir := filepath.Join("..", "..", "testdata", name) - - return func(t *testing.T, destdir string, metadata generate.Metadata) { - t.Helper() - - // Arrange - assertdir := filepath.Join(assertdir, path.Base(t.Name())) - - opts := generate.ExecOpts{ - FileHandlers: func() []generate.FileHandler { - metas := generate.MetaHandlers() - result := make([]generate.FileHandler, 0, len(metas)) - for _, handler := range metas { - result = append(result, handler(metadata)) - } - return result - }(), - EndDelim: ">>", - StartDelim: "<<", - ForceAll: true, - } - - // Act - err := exec(ctx, cfs.OS(), srcdir, destdir, metadata, opts) - - // Assert - require.NoError(t, err) - assert.NoError(t, testfs.EqualDirs(assertdir, destdir)) - } -} diff --git a/pkg/generate/generic.go b/pkg/generate/generic.go deleted file mode 100644 index e8dc7880..00000000 --- a/pkg/generate/generic.go +++ /dev/null @@ -1,23 +0,0 @@ -package generate - -import ( - "context" -) - -// DetectGeneric represents the detection for generic projects (those without any associated implemented language). -// -// It returns the input metadata but modified with appropriate properties -// alongside the slice of ExecFunc to be executed to templatize the project. -func DetectGeneric(_ context.Context, _ string, metadata *Metadata) ([]ExecFunc, error) { - if len(metadata.Languages) != 0 { - return nil, nil - } - - log.Warnf("no language detected, fallback to generic generation") - if metadata.CI != nil { - metadata.CI.Options = nil - } - return []ExecFunc{BasicExecFunc("lang_generic")}, nil -} - -var _ DetectFunc = DetectGeneric // ensure interface is implemented diff --git a/pkg/generate/generic_test.go b/pkg/generate/generic_test.go deleted file mode 100644 index fc99a5dc..00000000 --- a/pkg/generate/generic_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package generate_test - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/kilianpaquier/craft/pkg/craft" - "github.com/kilianpaquier/craft/pkg/generate" -) - -func TestDetectGeneric(t *testing.T) { - ctx := context.Background() - - t.Run("no_ci", func(t *testing.T) { - // Arrange - config := generate.Metadata{} - - // Act - exec, err := generate.DetectGeneric(ctx, "", &config) - - // Assert - require.NoError(t, err) - assert.Len(t, exec, 1) - assert.Zero(t, config) - }) - - t.Run("ci_options", func(t *testing.T) { - // Arrange - config := generate.Metadata{ - Configuration: craft.Configuration{CI: &craft.CI{ - Options: craft.CIOptions(), - }}, - } - expected := generate.Metadata{ - Configuration: craft.Configuration{CI: &craft.CI{}}, - } - - // Act - exec, err := generate.DetectGeneric(ctx, "", &config) - - // Assert - require.NoError(t, err) - assert.Len(t, exec, 1) - assert.Equal(t, expected, config) - }) -} diff --git a/pkg/generate/handler/delimiter.go b/pkg/generate/handler/delimiter.go new file mode 100644 index 00000000..3c6e1db3 --- /dev/null +++ b/pkg/generate/handler/delimiter.go @@ -0,0 +1,42 @@ +package handler + +// Delimiter represents the pair of start and end delimiter for go template substitution. +type Delimiter struct { + // EndDelim is the end delimiter of a go template statement, i.e. >> or }} or ]], etc. + EndDelim string + + // StartDelim is the start delimiter of a go template statement, i.e. << or {{ or [[, etc. + StartDelim string +} + +var ( + chevron = Delimiter{ + EndDelim: ">>", + StartDelim: "<<", + } + + bracket = Delimiter{ + EndDelim: "}}", + StartDelim: "{{", + } + + squareBracket = Delimiter{ + EndDelim: "]]", + StartDelim: "[[", + } +) + +// DelimiterChevron returns go template delimiter << and >>. +func DelimiterChevron() Delimiter { + return chevron +} + +// DelimiterBracket returns go template delimiter {{ and }}. +func DelimiterBracket() Delimiter { + return bracket +} + +// DelimiterSquareBracket returns go template delimiter [[ and ]]. +func DelimiterSquareBracket() Delimiter { + return squareBracket +} diff --git a/pkg/generate/handler/delimiter_test.go b/pkg/generate/handler/delimiter_test.go new file mode 100644 index 00000000..68a4068b --- /dev/null +++ b/pkg/generate/handler/delimiter_test.go @@ -0,0 +1,33 @@ +package handler //nolint:testpackage + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDelimiter(t *testing.T) { + t.Run("success_chevron", func(t *testing.T) { + // Act + delimiter := DelimiterChevron() + + // Assert + assert.Equal(t, chevron, delimiter) + }) + + t.Run("success_bracket", func(t *testing.T) { + // Act + delimiter := DelimiterBracket() + + // Assert + assert.Equal(t, bracket, delimiter) + }) + + t.Run("success_square_bracket", func(t *testing.T) { + // Act + delimiter := DelimiterSquareBracket() + + // Assert + assert.Equal(t, squareBracket, delimiter) + }) +} diff --git a/pkg/generate/handler/doc.go b/pkg/generate/handler/doc.go new file mode 100644 index 00000000..abeebd16 --- /dev/null +++ b/pkg/generate/handler/doc.go @@ -0,0 +1 @@ +package handler diff --git a/pkg/generate/handler/generated.go b/pkg/generate/handler/generated.go new file mode 100644 index 00000000..07466e13 --- /dev/null +++ b/pkg/generate/handler/generated.go @@ -0,0 +1,35 @@ +package handler + +import ( + "os" + "strings" +) + +// generated is the string for generated files. +const generated = "Code generated by craft; DO NOT EDIT." + +// IsGenerated returns truthy if input destination is a generated file. +func IsGenerated(dest string) bool { + // retrieve file content, if there's an error, generation to make + content, err := os.ReadFile(dest) + if err != nil { + return true + } + + // special case (shouldn't happen) where the destination has been replaced with an empty file + if len(content) == 0 { + return true + } + lines := strings.Split(string(content), "\n") + + // check first line for generated regexp + if len(lines) >= 1 && strings.Contains(lines[0], generated) { + return true + } + + // check second line for generated regexp + if len(lines) >= 2 && strings.Contains(lines[1], generated) { + return true + } + return false +} diff --git a/pkg/generate/handler/generated_test.go b/pkg/generate/handler/generated_test.go new file mode 100644 index 00000000..e5ea2076 --- /dev/null +++ b/pkg/generate/handler/generated_test.go @@ -0,0 +1,118 @@ +package handler_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/kilianpaquier/cli-sdk/pkg/cfs" + "github.com/kilianpaquier/craft/pkg/generate/handler" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestIsGenerated(t *testing.T) { + t.Run("generated_doesnt_exist", func(t *testing.T) { + // Arrange + dest := filepath.Join(t.TempDir(), "invalid.txt") + + // Act + generated := handler.IsGenerated(dest) + + // Assert + assert.True(t, generated) + }) + + t.Run("not_generated_file", func(t *testing.T) { + // Arrange + dest := filepath.Join(t.TempDir(), "file.txt") + err := os.WriteFile(dest, []byte("not generated"), cfs.RwRR) + require.NoError(t, err) + + // Act + generated := handler.IsGenerated(dest) + + // Assert + assert.False(t, generated) + }) + + t.Run("generated_folder", func(t *testing.T) { + // Arrange + dest := filepath.Join(t.TempDir(), "folder") + require.NoError(t, os.Mkdir(dest, cfs.RwxRxRxRx)) + + // Act + generated := handler.IsGenerated(dest) + + // Assert + assert.True(t, generated) + }) + + t.Run("generated_no_lines", func(t *testing.T) { + // Arrange + dest := filepath.Join(t.TempDir(), "file.txt") + file, err := os.Create(dest) + require.NoError(t, err) + t.Cleanup(func() { assert.NoError(t, file.Close()) }) + + // Act + generated := handler.IsGenerated(dest) + + // Assert + assert.True(t, generated) + }) + + t.Run("generated_first_line", func(t *testing.T) { + // Arrange + dest := filepath.Join(t.TempDir(), "file.txt") + err := os.WriteFile(dest, []byte("// Code generated by craft; DO NOT EDIT."), cfs.RwRR) + require.NoError(t, err) + + // Act + generated := handler.IsGenerated(dest) + + // Assert + assert.True(t, generated) + }) + + t.Run("generated_md_comment", func(t *testing.T) { + // Arrange + dest := filepath.Join(t.TempDir(), "file.txt") + err := os.WriteFile(dest, []byte(""), cfs.RwRR) + require.NoError(t, err) + + // Act + generated := handler.IsGenerated(dest) + + // Assert + assert.True(t, generated) + }) + + t.Run("generated_second_line", func(t *testing.T) { + // Arrange + dest := filepath.Join(t.TempDir(), "file.txt") + err := os.WriteFile(dest, []byte("\n# Code generated by craft; DO NOT EDIT."), cfs.RwRR) + require.NoError(t, err) + + // Act + generated := handler.IsGenerated(dest) + + // Assert + assert.True(t, generated) + }) + + t.Run("generated_json", func(t *testing.T) { + // Arrange + dest := filepath.Join(t.TempDir(), "file.txt") + err := os.WriteFile(dest, []byte(`{ + "//": "Code generated by craft; DO NOT EDIT.", + }`), cfs.RwRR) + require.NoError(t, err) + + // Act + generated := handler.IsGenerated(dest) + + // Assert + assert.True(t, generated) + }) +} diff --git a/pkg/generate/handler/github.go b/pkg/generate/handler/github.go new file mode 100644 index 00000000..1d6ccff2 --- /dev/null +++ b/pkg/generate/handler/github.go @@ -0,0 +1,85 @@ +package handler + +import ( + "path" + "slices" + "strings" + + "github.com/kilianpaquier/craft/pkg/craft" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +// GitHub returns the handler for GitHub specific files generation. +func GitHub(metadata generate.Metadata) Handler { + // files related to dir .github + config := githubConfig(metadata) + + // files related to dir .github/workflows + workflow := githubWorkflow(metadata) + + return func(src, dest, name string) (Result, bool) { + for _, handler := range []Handler{workflow, config} { + if result, ok := handler(src, dest, name); ok { + return result, ok + } + } + return Result{}, false + } +} + +// githubWorkflow returns the handler related to files in .github/workflows (github actions files). +func githubWorkflow(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + // files related to dir .github/workflows + // renovate.yml is handled by RenovateHandler + if name == "renovate.yml" || !strings.Contains(src, path.Join(".github", "workflows", name)) { + return Result{}, false + } + + result := Result{ + Delimiter: chevron, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return !metadata.IsCI(craft.GitHub) }, + } + + switch name { + case "ci.yml": + result.Globs = append(result.Globs, PartGlob(src, name)) + case "codeql.yml": + result.Remove = func() bool { + return !metadata.IsCI(craft.GitHub) || !slices.Contains(metadata.CI.Options, craft.CodeQL) + } + case "labeler.yml": + result.Remove = func() bool { + return !metadata.IsCI(craft.GitHub) || !slices.Contains(metadata.CI.Options, craft.Labeler) + } + } + return result, true + } +} + +// githubConfig returns the handler related to files in .github folder (github platform configuration files). +func githubConfig(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + // files related to dir .github + // dependabot.yml is handled by DependabotHandler + if name == "dependabot.yml" || !strings.Contains(src, path.Join(".github", name)) { + return Result{}, false + } + + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return metadata.Platform != craft.GitHub }, + } + + if name == "labeler.yml" { + result.Remove = func() bool { + return !metadata.IsCI(craft.GitHub) || !slices.Contains(metadata.CI.Options, craft.Labeler) + } + } + return result, true + } +} diff --git a/pkg/generate/handler/github_test.go b/pkg/generate/handler/github_test.go new file mode 100644 index 00000000..13e27077 --- /dev/null +++ b/pkg/generate/handler/github_test.go @@ -0,0 +1 @@ +package handler_test diff --git a/pkg/generate/handler/gitlab.go b/pkg/generate/handler/gitlab.go new file mode 100644 index 00000000..eec1e46f --- /dev/null +++ b/pkg/generate/handler/gitlab.go @@ -0,0 +1,74 @@ +package handler + +import ( + "path" + "strings" + + "github.com/kilianpaquier/craft/pkg/craft" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +// GitLab returns the handler for GitLab specific files generation. +func GitLab(metadata generate.Metadata) Handler { + // files related to dir .gitlab + config := gitlabConfig(metadata) + + // files related to dir .gitlab/workflows + workflow := gitlabWorkflow(metadata) + + return func(src, dest, name string) (Result, bool) { + for _, handler := range []Handler{workflow, config} { + if result, ok := handler(src, dest, name); ok { + return result, ok + } + } + + // root files related to gitlab + if name != ".gitlab-ci.yml" { + return Result{}, false + } + + result := Result{ + Delimiter: chevron, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return !metadata.IsCI(craft.GitLab) }, + } + return result, true + } +} + +func gitlabWorkflow(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + // files related to dir .gitlab/workflows + if !strings.Contains(src, path.Join(".gitlab", "workflows", name)) { + return Result{}, false + } + + result := Result{ + Delimiter: chevron, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return !metadata.IsCI(craft.GitLab) }, + } + return result, true + } +} + +func gitlabConfig(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + // files related to dir .gitlab + // semrel-plugins.txt.tmpl is handled by SemanticReleaseHandler + if name == "semrel-plugins.txt.tmpl" || !strings.Contains(src, path.Join(".gitlab", name)) { + return Result{}, false + } + + result := Result{ + Delimiter: chevron, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return metadata.Platform != craft.GitLab }, + } + return result, true + } +} diff --git a/pkg/generate/handler/gitlab_test.go b/pkg/generate/handler/gitlab_test.go new file mode 100644 index 00000000..13e27077 --- /dev/null +++ b/pkg/generate/handler/gitlab_test.go @@ -0,0 +1 @@ +package handler_test diff --git a/pkg/generate/handler/golang.go b/pkg/generate/handler/golang.go new file mode 100644 index 00000000..0413b3a7 --- /dev/null +++ b/pkg/generate/handler/golang.go @@ -0,0 +1,28 @@ +package handler + +import ( + "slices" + + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +// Golang returns the handler for goreleaser option generation matching. +func Golang(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + if !slices.Contains([]string{".golangci.yml", ".goreleaser.yml"}, name) { + return Result{}, false + } + _, ok := metadata.Languages["golang"] + + result := Result{ + Delimiter: chevron, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return !ok }, + } + if name == ".goreleaser.yml" { + result.Remove = func() bool { return metadata.NoGoreleaser || len(metadata.Clis) == 0 || !ok } + } + return result, true + } +} diff --git a/pkg/generate/handler/golang_test.go b/pkg/generate/handler/golang_test.go new file mode 100644 index 00000000..13e27077 --- /dev/null +++ b/pkg/generate/handler/golang_test.go @@ -0,0 +1 @@ +package handler_test diff --git a/pkg/generate/handler/handler.go b/pkg/generate/handler/handler.go new file mode 100644 index 00000000..36f40107 --- /dev/null +++ b/pkg/generate/handler/handler.go @@ -0,0 +1,75 @@ +package handler + +import ( + "fmt" + "path" + "path/filepath" + "strings" + + "github.com/kilianpaquier/craft/pkg/craft" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +// Result is the result of a Handler function. +type Result struct { + // Delimiter is the pair of delimiters to use for given handler result (as such a file or a bunch of files) + // during go template statements execution. + Delimiter + + // Generate function is run (if not nil) after Handler execution to check whether the current file should be generated or not. + // + // In case it must not be generated, then nothing is done. + // + // Note that Remove function (if not nil) is executed + // before Generate to check whether the current file should be removed from filesystem. + Generate func() bool + + // Globs is the slice of globs or specific files to parse during go templating. + // + // It allows the current file to be split into multiple template files + // with "define" go template statements to help readability. + Globs []string + + // Remove function is run (if not nil) after Handler execution to check + // whether the current file should be removed from filesystem or not. + Remove func() bool +} + +// Handler represents the function to retrieve specificities over an input file. +// +// In case a file doesn't have its Handler then it's ignored during template execution. +type Handler func(src, dest, name string) (Result, bool) + +// Defaults ... +func Defaults(metadata generate.Metadata) []Handler { + return []Handler{ + Git, + + CodeCov(metadata), + Dependabot(metadata), + Docker(metadata), + GitHub(metadata), + GitLab(metadata), + Golang(metadata), + Helm(metadata), + Makefile(metadata), + Readme(metadata), + Renovate(metadata), + SemanticRelease(metadata), + Sonar(metadata), + } +} + +// PartGlob returns the glob string for HandlerResult globs parts. +// +// It should be used when templating a file split into multiple templates. +// +// The result is of the form: Dockerfile-*.part.tmpl, ci-*.part.tmpl, .gitlab-ci-*.part.yml .gitignore-*.part.tmpl, etc. +func PartGlob(src, name string) string { + n := strings.TrimSuffix(name, filepath.Ext(name)) + if n == "" { + n = name + } + glob := fmt.Sprint(n, "-*", craft.PartExtension, craft.TmplExtension) + return path.Join(filepath.Dir(src), glob) +} diff --git a/pkg/generate/handler/handler_test.go b/pkg/generate/handler/handler_test.go new file mode 100644 index 00000000..195f685d --- /dev/null +++ b/pkg/generate/handler/handler_test.go @@ -0,0 +1,54 @@ +package handler_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +func TestDefaultHandlers(t *testing.T) { + t.Run("success", func(t *testing.T) { + // Act + handlers := handler.Defaults(generate.Metadata{}) + + // Assert + assert.Len(t, handlers, 13) + }) +} + +func TestPartGlob(t *testing.T) { + t.Run("success_gitignore", func(t *testing.T) { + // Act + part := handler.PartGlob("", ".gitignore") + + // Assert + assert.Equal(t, ".gitignore-*.part.tmpl", part) + }) + + t.Run("success_dockerfile", func(t *testing.T) { + // Act + part := handler.PartGlob("", "Dockerfile") + + // Assert + assert.Equal(t, "Dockerfile-*.part.tmpl", part) + }) + + t.Run("success_codecov", func(t *testing.T) { + // Act + part := handler.PartGlob("", ".codecov.yml") + + // Assert + assert.Equal(t, ".codecov-*.part.tmpl", part) + }) + + t.Run("success_values", func(t *testing.T) { + // Act + part := handler.PartGlob("templates/path/to/dir/values.yaml", "values.yaml") + + // Assert + assert.Equal(t, "templates/path/to/dir/values-*.part.tmpl", part) + }) +} diff --git a/pkg/generate/handler/helm.go b/pkg/generate/handler/helm.go new file mode 100644 index 00000000..f88a3689 --- /dev/null +++ b/pkg/generate/handler/helm.go @@ -0,0 +1,90 @@ +package handler + +import ( + "path" + "strings" + + "github.com/kilianpaquier/cli-sdk/pkg/cfs" + + "github.com/kilianpaquier/craft/pkg/craft" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +// Helm returns the handler for chart folder generation. +func Helm(metadata generate.Metadata) Handler { + // files related to dir chart/templates + templates := helmTemplates(metadata) + + // files related to dir chart/charts + charts := helmCharts(metadata) + + // files related to dir chart + config := helmConfig(metadata) + + return func(src, dest, name string) (Result, bool) { + for _, handler := range []Handler{templates, charts, config} { + if result, ok := handler(src, dest, name); ok { + return result, ok + } + } + return Result{}, false + } +} + +func helmTemplates(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + // files related to dir chart/templates + if !strings.Contains(src, path.Join("chart", "templates", name)) { + return Result{}, false + } + + result := Result{ + Delimiter: chevron, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return metadata.NoChart }, + } + return result, true + } +} + +func helmCharts(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + // files related to dir chart/charts + if !strings.Contains(src, path.Join("chart", "charts", name)) { + return Result{}, false + } + + result := Result{ + Delimiter: chevron, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return metadata.NoChart }, + } + return result, true + } +} + +func helmConfig(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + // files related to dir chart + if !strings.Contains(src, path.Join("chart", name)) { + return Result{}, false + } + + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return metadata.NoChart }, + } + + switch name { + case craft.File: + result.Generate = func() bool { return !cfs.Exists(dest) } + case "values.yaml": + result.Globs = append(result.Globs, PartGlob(src, name)) + } + return result, true + } +} diff --git a/pkg/generate/handler/helm_test.go b/pkg/generate/handler/helm_test.go new file mode 100644 index 00000000..13e27077 --- /dev/null +++ b/pkg/generate/handler/helm_test.go @@ -0,0 +1 @@ +package handler_test diff --git a/pkg/generate/handler/standard.go b/pkg/generate/handler/standard.go new file mode 100644 index 00000000..80821897 --- /dev/null +++ b/pkg/generate/handler/standard.go @@ -0,0 +1,186 @@ +package handler + +import ( + "path/filepath" + "slices" + + "github.com/kilianpaquier/cli-sdk/pkg/cfs" + + "github.com/kilianpaquier/craft/pkg/craft" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +// CodeCov returns the handler for codecov generation. +func CodeCov(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + if name != ".codecov.yml" { + return Result{}, false + } + + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { + return !metadata.IsCI(craft.GitHub) || !slices.Contains(metadata.CI.Options, craft.CodeCov) + }, + } + return result, true + } +} + +// Dependabot returns the handler for dependabot files generation. +func Dependabot(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + if name != "dependabot.yml" { + return Result{}, false + } + + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return metadata.Platform != craft.GitHub || !metadata.IsBot(craft.Dependabot) }, + } + return result, true + } +} + +// Docker returns the handler for Docker files generation. +func Docker(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + } + + switch name { + case "Dockerfile": + result.Globs = append(result.Globs, PartGlob(src, name)) + result.Remove = func() bool { return metadata.Docker == nil } + case ".dockerignore": + result.Remove = func() bool { return metadata.Docker == nil } + case "launcher.sh": + // launcher.sh is a specific thing to golang being able to have multiple binaries inside a simple project (cmd folder) + // however, it may change in the future with python (or rust or others ?) depending of flexibility in repositories layout + _, ok := metadata.Languages["golang"] + result.Remove = func() bool { return metadata.Docker == nil || metadata.Binaries <= 1 || !ok } + default: + return Result{}, false + } + return result, true + } +} + +// Git is the handler for git specific files generation. +func Git(src, dest, name string) (Result, bool) { + if name != ".gitignore" { + return Result{}, false + } + + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src, PartGlob(src, name)}, + } + return result, true +} + +// Makefile returns the handler for Makefile(s) generation. +func Makefile(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + if name != "Makefile" || filepath.Ext(name) != ".mk" { + return Result{}, false + } + + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { + _, ok := metadata.Languages["nodejs"] // don't generate makefiles with nodejs + return metadata.NoMakefile || ok + }, + } + return result, true + } +} + +// Readme returns the handler for README.md generation. +func Readme(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + if name != "README.md" { + return Result{}, false + } + + result := Result{ + Delimiter: bracket, + Generate: func() bool { return !metadata.NoReadme && !cfs.Exists(dest) }, + Globs: []string{src}, + } + return result, true + } +} + +// SemanticRelease returns the handler for releaserc generation. +func SemanticRelease(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + } + + switch name { + case ".releaserc.yml": + result.Remove = func() bool { return !metadata.HasRelease() } + case "semrel-plugins.txt": + result.Generate = func() bool { return true } // always generate semrel-plugins.txt + result.Remove = func() bool { return !metadata.HasRelease() || !metadata.IsCI(craft.GitLab) } + default: + return Result{}, false + } + return result, true + } +} + +// Renovate returns the handler for renovate bot files generation. +func Renovate(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + result := Result{ + Delimiter: chevron, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + } + + switch name { + case "renovate.yml": + result.Remove = func() bool { + return !metadata.IsBot(craft.Renovate) || !metadata.IsCI(craft.GitHub) || (metadata.CI.Auth.Maintenance != nil && *metadata.CI.Auth.Maintenance == craft.Mendio) //nolint:revive + } + case "renovate.json5": + result.Remove = func() bool { return !metadata.IsBot(craft.Renovate) } + default: + return Result{}, false + } + return result, true + } +} + +// Sonar returns the handler for Sonar generation. +func Sonar(metadata generate.Metadata) Handler { + return func(src, dest, name string) (Result, bool) { + if name != "sonar.properties" { + return Result{}, false + } + + result := Result{ + Delimiter: bracket, + Generate: func() bool { return IsGenerated(dest) }, + Globs: []string{src}, + Remove: func() bool { return metadata.CI == nil || !slices.Contains(metadata.CI.Options, craft.Sonar) }, + } + return result, true + } +} diff --git a/pkg/generate/handler/standard_test.go b/pkg/generate/handler/standard_test.go new file mode 100644 index 00000000..13e27077 --- /dev/null +++ b/pkg/generate/handler/standard_test.go @@ -0,0 +1 @@ +package handler_test diff --git a/pkg/generate/helm.go b/pkg/generate/helm.go deleted file mode 100644 index d4143b75..00000000 --- a/pkg/generate/helm.go +++ /dev/null @@ -1,65 +0,0 @@ -package generate - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "io/fs" - "os" - "path" - "path/filepath" - - "dario.cat/mergo" - "github.com/kilianpaquier/cli-sdk/pkg/cfs" - - "github.com/kilianpaquier/craft/pkg/craft" -) - -// DetectHelm handles the detection of helm chart generation option in metadata -// and returns the appropriate slice of ExecFunc. -func DetectHelm(_ context.Context, _ string, metadata *Metadata) ([]ExecFunc, error) { - if metadata.NoChart { - return []ExecFunc{removeHelm}, nil - } - - log.Infof("helm chart detected, %s doesn't have no_chart key", craft.File) - return []ExecFunc{generateHelm}, nil -} - -var _ DetectFunc = DetectHelm // ensure interface is implemented - -// generateHelm generates the appropriate helm chart at destdir. -// -// To be able to use the maximum number of variables in templates (in input fsys inside helm folder), -// a marshal is applied on input config and on {{destdir}}/chart/.craft. -func generateHelm(_ context.Context, fsys cfs.FS, srcdir, destdir string, metadata Metadata, opts ExecOpts) error { - helmdir := path.Join(srcdir, "lang_helm") - chartdir := filepath.Join(destdir, "chart") - - // transform craft configuration into generic chart configuration (easier to maintain) - var chart map[string]any - bytes, _ := json.Marshal(metadata) - _ = json.Unmarshal(bytes, &chart) - - // read overrides values - var overrides map[string]any - if err := craft.Read(chartdir, &overrides); err != nil && !errors.Is(err, fs.ErrNotExist) { - return fmt.Errorf("read helm chart overrides: %w", err) - } - - // merge overrides into chart with overwrite - if err := mergo.Merge(&chart, overrides, mergo.WithOverride); err != nil { - return fmt.Errorf("merge helm chart overrides with craft configuration: %w", err) - } - - return handleDir(fsys, helmdir, chartdir, chart, "helm", opts) -} - -// removeHelm deletes the chart folder inside destdir. -func removeHelm(_ context.Context, _ cfs.FS, _, destdir string, _ Metadata, _ ExecOpts) error { - if err := os.RemoveAll(filepath.Join(destdir, "chart")); err != nil { - return fmt.Errorf("delete directory: %w", err) - } - return nil -} diff --git a/pkg/generate/helm_test.go b/pkg/generate/helm_test.go deleted file mode 100644 index 85d13810..00000000 --- a/pkg/generate/helm_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package generate_test - -import ( - "context" - "os" - "path/filepath" - "testing" - - "github.com/kilianpaquier/cli-sdk/pkg/cfs" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/kilianpaquier/craft/internal/helpers" - "github.com/kilianpaquier/craft/pkg/craft" - "github.com/kilianpaquier/craft/pkg/generate" -) - -func TestGenerateHelm(t *testing.T) { - ctx := context.Background() - - execs, err := generate.DetectHelm(ctx, "", &generate.Metadata{}) - require.NoError(t, err) - require.Len(t, execs, 1) - - setup := func(metadata generate.Metadata) generate.Metadata { - metadata.Maintainers = []*craft.Maintainer{{Name: "maintainer name"}} - metadata.ProjectHost = "example.com" - metadata.ProjectName = "craft" - metadata.ProjectPath = "kilianpaquier/craft" - return metadata - } - - verify := test(ctx, execs[0], "helm") - - t.Run("error_invalid_overrides", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - overrides := filepath.Join(destdir, "chart", craft.File) - require.NoError(t, os.MkdirAll(overrides, cfs.RwxRxRxRx)) - - metadata := setup(generate.Metadata{}) - - // Act - err := execs[0](ctx, cfs.OS(), "", destdir, metadata, generate.ExecOpts{}) - - // Assert - assert.ErrorContains(t, err, "read helm chart overrides") - }) - - t.Run("success_empty_values", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{}) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_dependencies", func(t *testing.T) { - // Arrange - assertdir := filepath.Join("..", "..", "testdata", "helm", "success_dependencies") - destdir := t.TempDir() - - require.NoError(t, os.Mkdir(filepath.Join(destdir, "chart"), cfs.RwxRxRxRx)) - err := cfs.CopyFile(filepath.Join(assertdir, "chart", ".craft"), filepath.Join(destdir, "chart", ".craft")) - require.NoError(t, err) - - metadata := setup(generate.Metadata{}) - - // Act & Assert - verify(t, destdir, metadata) - }) - - t.Run("success_resources", func(t *testing.T) { - // Arrange - metadata := setup(generate.Metadata{ - Clis: map[string]struct{}{"cli-name": {}}, - Configuration: craft.Configuration{ - Docker: &craft.Docker{Port: helpers.ToPtr(uint16(5000))}, - }, - Crons: map[string]struct{}{"cron-name": {}}, - Jobs: map[string]struct{}{"job-name": {}}, - Workers: map[string]struct{}{"worker-name": {}}, - }) - destdir := t.TempDir() - - // Act & Assert - verify(t, destdir, metadata) - }) -} - -func TestRemoveHelm(t *testing.T) { - ctx := context.Background() - - execs, err := generate.DetectHelm(ctx, "", &generate.Metadata{Configuration: craft.Configuration{NoChart: true}}) - require.NoError(t, err) - require.Len(t, execs, 1) - - t.Run("success_no_dir", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - chart := filepath.Join(destdir, "chart") - - // Act - err := execs[0](ctx, nil, "", destdir, generate.Metadata{}, generate.ExecOpts{}) - - // Assert - require.NoError(t, err) - assert.NoDirExists(t, chart) - }) - - t.Run("success_with_dir", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - chart := filepath.Join(destdir, "chart") - require.NoError(t, os.Mkdir(chart, cfs.RwxRxRxRx)) - - // Act - err := execs[0](ctx, nil, "", destdir, generate.Metadata{}, generate.ExecOpts{}) - - // Assert - require.NoError(t, err) - assert.NoDirExists(t, chart) - }) -} diff --git a/pkg/generate/license.go b/pkg/generate/license.go deleted file mode 100644 index 9c937af7..00000000 --- a/pkg/generate/license.go +++ /dev/null @@ -1,88 +0,0 @@ -package generate - -import ( - "context" - "errors" - "fmt" - "io/fs" - "os" - "path/filepath" - "slices" - - "github.com/hashicorp/go-cleanhttp" - "github.com/kilianpaquier/cli-sdk/pkg/cfs" - "github.com/xanzy/go-gitlab" - - "github.com/kilianpaquier/craft/pkg/craft" -) - -// GitLabURL is the default GitLab API URL. -const GitLabURL = "https://gitlab.com/api/v4" - -// DetectLicense handles the detection of license option in craft configuration. -// It also initializes a gitlab client to retrieve the appropriate license in returned slice of GenerateFunc. -func DetectLicense(ctx context.Context, _ string, metadata *Metadata) ([]ExecFunc, error) { - if metadata.License == nil { - return []ExecFunc{removeLicense}, nil - } - - client, err := gitlab.NewClient(os.Getenv("GITLAB_TOKEN"), - gitlab.WithBaseURL(GitLabURL), - gitlab.WithHTTPClient(cleanhttp.DefaultClient()), - gitlab.WithoutRetries(), - gitlab.WithRequestOptions(gitlab.WithContext(ctx))) - if err != nil { - // should never happen since it's gitlab.ClientOptionFunc that are throwing errors - // and currently WithBaseURL with fixed URL - // and WithoutRetries won't throw errors - // but in any case err must be handled in case it evolves or other options are added - log.Warnf("failed to initialize gitlab client in license detection, skipping license generation: %s", err.Error()) - return nil, nil - } - - log.Infof("license detected, %s has license key", craft.File) - return []ExecFunc{downloadLicense(client)}, nil -} - -var _ DetectFunc = DetectLicense // ensure interface is implemented - -// downloadLicense returns the GenerateFunc to download the appropriate license file from gitlab API. -func downloadLicense(client *gitlab.Client) ExecFunc { - return func(ctx context.Context, _ cfs.FS, _, destdir string, metadata Metadata, opts ExecOpts) error { - dest := filepath.Join(destdir, craft.License) - - // don't fetch template is force on file or force all isn't activated - if !opts.ForceAll && cfs.Exists(dest) && !slices.Contains(opts.Force, craft.License) { - return nil - } - - // fetch license template - options := &gitlab.GetLicenseTemplateOptions{ - Fullname: &metadata.Maintainers[0].Name, - Project: &metadata.ProjectName, - } - license, _, err := client.LicenseTemplates.GetLicenseTemplate(*metadata.License, options, gitlab.WithContext(ctx)) - if err != nil { - return fmt.Errorf("license template retrieval: %w", err) - } - - // remove file before rewritting it (in case rights changed) - if err := os.Remove(dest); err != nil && !errors.Is(err, fs.ErrNotExist) { - return fmt.Errorf("delete file: %w", err) - } - - // write license template - if err := os.WriteFile(dest, []byte(license.Content), cfs.RwRR); err != nil { - return fmt.Errorf("write file: %w", err) - } - return nil - } -} - -// removeLicense deletes the license file in input destdir. -func removeLicense(_ context.Context, _ cfs.FS, _, destdir string, _ Metadata, _ ExecOpts) error { - if err := os.Remove(filepath.Join(destdir, craft.License)); err != nil && !errors.Is(err, fs.ErrNotExist) { - return fmt.Errorf("delete file: %w", err) - } - return nil -} diff --git a/pkg/generate/license_test.go b/pkg/generate/license_test.go deleted file mode 100644 index c50da897..00000000 --- a/pkg/generate/license_test.go +++ /dev/null @@ -1,296 +0,0 @@ -package generate //nolint:testpackage - -import ( - "bytes" - "context" - "fmt" - stdlog "log" - "net/http" - "os" - "path/filepath" - "testing" - - "github.com/hashicorp/go-cleanhttp" - "github.com/jarcoal/httpmock" - "github.com/kilianpaquier/cli-sdk/pkg/cfs" - "github.com/kilianpaquier/cli-sdk/pkg/clog" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/xanzy/go-gitlab" - - "github.com/kilianpaquier/craft/internal/helpers" - "github.com/kilianpaquier/craft/pkg/craft" -) - -func TestDetectLicense(t *testing.T) { - ctx := context.Background() - - logs := func(t *testing.T) *bytes.Buffer { - t.Helper() - - var buf bytes.Buffer - log = clog.StdWith(stdlog.New(&buf, "", stdlog.LstdFlags)) - t.Cleanup(func() { log = clog.Noop() }) - return &buf - } - - t.Run("no_license_detected", func(t *testing.T) { - // Arrange - buf := logs(t) - - // Act - exec, err := DetectLicense(ctx, "", &Metadata{}) - - // Assert - require.NoError(t, err) - assert.Len(t, exec, 1) - assert.NotContains(t, buf.String(), fmt.Sprintf("license detected, %s has license key", craft.File)) - }) - - t.Run("license_detected", func(t *testing.T) { - // Arrange - buf := logs(t) - config := Metadata{Configuration: craft.Configuration{License: helpers.ToPtr("mit")}} - - // Act - exec, err := DetectLicense(ctx, "", &config) - - // Assert - require.NoError(t, err) - assert.Len(t, exec, 1) - assert.Contains(t, buf.String(), fmt.Sprintf("license detected, %s has license key", craft.File)) - }) -} - -func TestDownloadLicense(t *testing.T) { - ctx := context.Background() - - httpClient := cleanhttp.DefaultClient() - httpmock.ActivateNonDefault(httpClient) - t.Cleanup(httpmock.DeactivateAndReset) - - client, err := gitlab.NewClient("", - gitlab.WithBaseURL(GitLabURL), - gitlab.WithHTTPClient(httpClient), - gitlab.WithoutRetries(), - ) - require.NoError(t, err) - - url := GitLabURL + "/templates/licenses/mit" - - t.Run("error_get_template", func(t *testing.T) { - // Arrange - t.Cleanup(httpmock.Reset) - httpmock.RegisterResponder(http.MethodGet, url, - httpmock.NewStringResponder(http.StatusInternalServerError, "error message")) - - destdir := t.TempDir() - config := Metadata{ - Configuration: craft.Configuration{ - License: helpers.ToPtr("mit"), - Maintainers: []*craft.Maintainer{{Name: "name"}}, - }, - ProjectName: "craft", - } - - // Act - err := downloadLicense(client)(ctx, cfs.OS(), "", destdir, config, ExecOpts{}) - - // Assert - assert.ErrorContains(t, err, "license template retrieval") - }) - - t.Run("error_write_license", func(t *testing.T) { - // Arrange - t.Cleanup(httpmock.Reset) - httpmock.RegisterResponder(http.MethodGet, url, - httpmock.NewJsonResponderOrPanic(http.StatusOK, gitlab.LicenseTemplate{Content: "some content to appear in assert"})) - - destdir := t.TempDir() - dest := filepath.Join(destdir, craft.License) - require.NoError(t, os.MkdirAll(filepath.Join(dest, "file.txt"), cfs.RwxRxRxRx)) - - config := Metadata{ - Configuration: craft.Configuration{ - License: helpers.ToPtr("mit"), - Maintainers: []*craft.Maintainer{{Name: "name"}}, - }, - ProjectName: "craft", - } - opts := ExecOpts{Force: []string{craft.License}} - - // Act - err := downloadLicense(client)(ctx, cfs.OS(), "", destdir, config, opts) - - // Assert - assert.ErrorContains(t, err, "delete file") - }) - - t.Run("success_no_specific_config", func(t *testing.T) { - // Arrange - t.Cleanup(httpmock.Reset) - httpmock.RegisterResponder(http.MethodGet, url, - httpmock.NewJsonResponderOrPanic(http.StatusOK, gitlab.LicenseTemplate{Content: "some content to appear in assert"})) - - destdir := t.TempDir() - dest := filepath.Join(destdir, craft.License) - - config := Metadata{ - Configuration: craft.Configuration{ - License: helpers.ToPtr("mit"), - Maintainers: []*craft.Maintainer{{Name: "name"}}, - }, - ProjectName: "craft", - } - - // Act - err := downloadLicense(client)(ctx, cfs.OS(), "", destdir, config, ExecOpts{}) - - // Assert - require.NoError(t, err) - bytes, err := os.ReadFile(dest) - require.NoError(t, err) - assert.Equal(t, "some content to appear in assert", string(bytes)) - assert.Equal(t, 1, httpmock.GetTotalCallCount()) - }) - - t.Run("success_no_call", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - dest := filepath.Join(destdir, craft.License) - - file, err := os.Create(dest) - require.NoError(t, err) - require.NoError(t, file.Close()) - - config := Metadata{ - Configuration: craft.Configuration{ - License: helpers.ToPtr("mit"), - Maintainers: []*craft.Maintainer{{Name: "name"}}, - }, - ProjectName: "craft", - } - - // Act - err = downloadLicense(client)(ctx, cfs.OS(), "", destdir, config, ExecOpts{}) - - // Assert - require.NoError(t, err) - assert.Equal(t, 0, httpmock.GetTotalCallCount()) - }) - - t.Run("success_force_option", func(t *testing.T) { - // Arrange - t.Cleanup(httpmock.Reset) - httpmock.RegisterResponder(http.MethodGet, url, - httpmock.NewJsonResponderOrPanic(http.StatusOK, gitlab.LicenseTemplate{Content: "some content to appear in assert"})) - - destdir := t.TempDir() - dest := filepath.Join(destdir, craft.License) - - file, err := os.Create(dest) - require.NoError(t, err) - require.NoError(t, file.Close()) - - config := Metadata{ - Configuration: craft.Configuration{ - License: helpers.ToPtr("mit"), - Maintainers: []*craft.Maintainer{{Name: "name"}}, - }, - ProjectName: "craft", - } - opts := ExecOpts{Force: []string{craft.License}} - - // Act - err = downloadLicense(client)(ctx, cfs.OS(), "", destdir, config, opts) - - // Assert - require.NoError(t, err) - bytes, err := os.ReadFile(dest) - require.NoError(t, err) - assert.Equal(t, "some content to appear in assert", string(bytes)) - assert.Equal(t, 1, httpmock.GetTotalCallCount()) - }) - - t.Run("success_force_all_option", func(t *testing.T) { - // Arrange - t.Cleanup(httpmock.Reset) - httpmock.RegisterResponder(http.MethodGet, url, - httpmock.NewJsonResponderOrPanic(http.StatusOK, gitlab.LicenseTemplate{Content: "some content to appear in assert"})) - - destdir := t.TempDir() - dest := filepath.Join(destdir, craft.License) - - file, err := os.Create(dest) - require.NoError(t, err) - require.NoError(t, file.Close()) - - config := Metadata{ - Configuration: craft.Configuration{ - License: helpers.ToPtr("mit"), - Maintainers: []*craft.Maintainer{{Name: "name"}}, - }, - ProjectName: "craft", - } - opts := ExecOpts{ForceAll: true} - - // Act - err = downloadLicense(client)(ctx, cfs.OS(), "", destdir, config, opts) - - // Assert - require.NoError(t, err) - bytes, err := os.ReadFile(dest) - require.NoError(t, err) - assert.Equal(t, "some content to appear in assert", string(bytes)) - assert.Equal(t, 1, httpmock.GetTotalCallCount()) - }) -} - -func TestRemoveLicense(t *testing.T) { - ctx := context.Background() - - t.Run("error_remove_file", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - - dest := filepath.Join(destdir, craft.License) - require.NoError(t, os.MkdirAll(filepath.Join(dest, "file.txt"), cfs.RwxRxRxRx)) - - // Act - err := removeLicense(ctx, cfs.OS(), "", destdir, Metadata{}, ExecOpts{}) - - // Assert - assert.ErrorContains(t, err, "delete file") - }) - - t.Run("success_no_file", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - - dest := filepath.Join(destdir, craft.License) - - // Act - err := removeLicense(ctx, cfs.OS(), "", destdir, Metadata{}, ExecOpts{}) - - // Assert - require.NoError(t, err) - assert.NoFileExists(t, dest) - }) - - t.Run("success_with_file", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - - dest := filepath.Join(destdir, craft.License) - file, err := os.Create(dest) - require.NoError(t, err) - require.NoError(t, file.Close()) - - // Act - err = removeLicense(ctx, cfs.OS(), "", destdir, Metadata{}, ExecOpts{}) - - // Assert - require.NoError(t, err) - assert.NoFileExists(t, dest) - }) -} diff --git a/pkg/generate/logger.go b/pkg/generate/logger.go new file mode 100644 index 00000000..d6f36e4b --- /dev/null +++ b/pkg/generate/logger.go @@ -0,0 +1,19 @@ +package generate + +import ( + "github.com/kilianpaquier/cli-sdk/pkg/clog" + + "github.com/kilianpaquier/craft/pkg/generate/parser" +) + +var log clog.Logger = clog.Noop() + +// SetLogger sets the global logger for generate package. +// +// In case the input logger is nil, then nothing is done to avoid panics. +func SetLogger(input clog.Logger) { + if input != nil { + log = input + } + parser.SetLogger(input) +} diff --git a/pkg/generate/parser/doc.go b/pkg/generate/parser/doc.go new file mode 100644 index 00000000..0bfe2c25 --- /dev/null +++ b/pkg/generate/parser/doc.go @@ -0,0 +1 @@ +package parser diff --git a/pkg/generate/remote.go b/pkg/generate/parser/git.go similarity index 54% rename from pkg/generate/remote.go rename to pkg/generate/parser/git.go index de7cf9b3..44588329 100644 --- a/pkg/generate/remote.go +++ b/pkg/generate/parser/git.go @@ -1,15 +1,41 @@ -package generate +package parser import ( + "context" "fmt" "os/exec" + "path" "strings" "github.com/kilianpaquier/craft/pkg/craft" + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" ) -// OriginURL returns input directory git config --get remote.origin.url. -func OriginURL(destdir string) (string, error) { +// Git reads the input destdir directory remote.origin.url to retrieve various project information (git host, project name, etc.). +func Git(_ context.Context, destdir string, metadata *generate.Metadata) ([]handler.Handler, error) { + rawRemote, err := originURL(destdir) + if err != nil { + log.Warnf("failed to retrieve git remote.origin.url: %s", err.Error()) + return nil, nil + } + log.Infof("git repository detected") + + host, subpath := parseRemote(rawRemote) + if metadata.Platform == "" { + metadata.Platform, _ = parsePlatform(host) + } + + metadata.ProjectHost = host + metadata.ProjectName = path.Base(subpath) + metadata.ProjectPath = subpath + return nil, nil +} + +var _ Parser = Git // ensure interface is implemented + +// originURL returns input directory git config --get remote.origin.url. +func originURL(destdir string) (string, error) { cmd := exec.Command("git", "config", "--get", "remote.origin.url") cmd.Dir = destdir @@ -23,8 +49,8 @@ func OriginURL(destdir string) (string, error) { return string(out), nil } -// ParseRemote returns the current repository host and path to repository on the given host's platform. -func ParseRemote(rawRemote string) (host, path string) { +// parseRemote returns the current repository host and path to repository on the given host's platform. +func parseRemote(rawRemote string) (_, _ string) { if rawRemote == "" { return "", "" } @@ -46,8 +72,8 @@ func ParseRemote(rawRemote string) (host, path string) { return host, subpath } -// ParsePlatform returns the platform name associated to input host. -func ParsePlatform(host string) (string, bool) { +// parsePlatform returns the platform name associated to input host. +func parsePlatform(host string) (string, bool) { matchers := map[string][]string{ craft.Bitbucket: {"bb", craft.Bitbucket, "stash"}, craft.Gitea: {craft.Gitea}, diff --git a/pkg/generate/parser/git_test.go b/pkg/generate/parser/git_test.go new file mode 100644 index 00000000..69f8125e --- /dev/null +++ b/pkg/generate/parser/git_test.go @@ -0,0 +1,6 @@ +package parser_test + +import "testing" + +func TestGit(t *testing.T) { +} diff --git a/pkg/generate/golang.go b/pkg/generate/parser/golang.go similarity index 70% rename from pkg/generate/golang.go rename to pkg/generate/parser/golang.go index 6a602da2..342bee5c 100644 --- a/pkg/generate/golang.go +++ b/pkg/generate/parser/golang.go @@ -1,4 +1,4 @@ -package generate +package parser import ( "context" @@ -9,17 +9,21 @@ import ( "path" "path/filepath" "regexp" - "slices" "strings" "golang.org/x/mod/modfile" "github.com/kilianpaquier/craft/pkg/craft" + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" ) var ( - errMissingModuleStatement = errors.New("invalid go.mod, module statement is missing") - errMissingGoStatement = errors.New("invalid go.mod, go statement is missing") + // ErrMissingModuleStatement is the error returned when module statement is missing from go.mod. + ErrMissingModuleStatement = errors.New("invalid go.mod, module statement is missing") + + // ErrMissingGoStatement is the error returned when go statement is missing from go.mod. + ErrMissingGoStatement = errors.New("invalid go.mod, go statement is missing") ) var versionRegexp = regexp.MustCompile("^v[0-9]+$") @@ -33,10 +37,10 @@ type Gomod struct { ProjectPath string } -// DetectGolang handles the detection of golang at destdir. +// Golang handles the parsing of a golang repository at destdir. // // A valid golang project must have a valid go.mod file. -func DetectGolang(ctx context.Context, destdir string, metadata *Metadata) ([]ExecFunc, error) { +func Golang(ctx context.Context, destdir string, metadata *generate.Metadata) ([]handler.Handler, error) { gomod := filepath.Join(destdir, craft.Gomod) gocmd := filepath.Join(destdir, craft.Gocmd) @@ -44,7 +48,7 @@ func DetectGolang(ctx context.Context, destdir string, metadata *Metadata) ([]Ex statements, err := readGomod(gomod) if err != nil { if !errors.Is(err, fs.ErrNotExist) { - return nil, fmt.Errorf("read go.mod: %w", err) + return nil, fmt.Errorf("read %s: %w", craft.Gomod, err) } return nil, nil } @@ -54,12 +58,12 @@ func DetectGolang(ctx context.Context, destdir string, metadata *Metadata) ([]Ex metadata.ProjectName = statements.ProjectName metadata.ProjectPath = statements.ProjectPath - // check hugo detection - if execs, _ := detectHugo(ctx, destdir, metadata); len(execs) > 0 { - return execs, nil + // check hugo repository + if ok := isHugo(ctx, destdir, metadata); ok { + return nil, nil } - log.Infof("golang detected, a %s is present and valid", craft.Gomod) + log.Infof("golang detected, file '%s' is present and valid", craft.Gomod) metadata.Languages["golang"] = statements entries, err := os.ReadDir(gocmd) @@ -84,14 +88,12 @@ func DetectGolang(ctx context.Context, destdir string, metadata *Metadata) ([]Ex metadata.Binaries++ } } - - return []ExecFunc{BasicExecFunc("lang_golang")}, nil + return nil, nil } -var _ DetectFunc = DetectGolang // ensure interface is implemented +var _ Parser = Golang // ensure interface is implemented -// detectHugo handles the detection of hugo at destdir. -func detectHugo(_ context.Context, destdir string, metadata *Metadata) ([]ExecFunc, error) { +func isHugo(_ context.Context, destdir string, metadata *generate.Metadata) bool { // detect hugo project configs, _ := filepath.Glob(filepath.Join(destdir, "hugo.*")) @@ -100,22 +102,12 @@ func detectHugo(_ context.Context, destdir string, metadata *Metadata) ([]ExecFu if len(configs) > 0 || len(themes) > 0 { log.Infof("hugo detected, a hugo configuration file or hugo theme file is present") - - if metadata.CI != nil { - log.Warnf("removing codecov, codeql and sonar option from CI since they're not available with hugo projects") - metadata.CI.Options = slices.DeleteFunc(metadata.CI.Options, func(option string) bool { - return slices.Contains([]string{craft.CodeCov, craft.CodeQL, craft.Sonar}, option) - }) - } - metadata.Languages["hugo"] = nil - return []ExecFunc{BasicExecFunc("lang_hugo")}, nil + return true } - return nil, nil + return false } -var _ DetectFunc = detectHugo // ensure interface is implemented - // readGomod reads the go.mod file at modpath input and returns its gomod representation. func readGomod(modpath string) (Gomod, error) { // read go.mod at modpath @@ -135,7 +127,7 @@ func readGomod(modpath string) (Gomod, error) { // parse module statement if file.Module == nil || file.Module.Mod.Path == "" { - errs = append(errs, errMissingModuleStatement) + errs = append(errs, ErrMissingModuleStatement) } else { gomod.ProjectHost, gomod.ProjectPath = func() (host, subpath string) { sections := strings.Split(file.Module.Mod.Path, "/") @@ -144,13 +136,13 @@ func readGomod(modpath string) (Gomod, error) { } return sections[0], strings.Join(sections[1:], "/") // retrieve all sections }() - gomod.Platform, _ = ParsePlatform(gomod.ProjectHost) + gomod.Platform, _ = parsePlatform(gomod.ProjectHost) gomod.ProjectName = path.Base(gomod.ProjectPath) } // parse go statement if file.Go == nil { - errs = append(errs, errMissingGoStatement) + errs = append(errs, ErrMissingGoStatement) } else { gomod.LangVersion = file.Go.Version } diff --git a/pkg/generate/golang_test.go b/pkg/generate/parser/golang_test.go similarity index 80% rename from pkg/generate/golang_test.go rename to pkg/generate/parser/golang_test.go index 9da69c67..a427d2f4 100644 --- a/pkg/generate/golang_test.go +++ b/pkg/generate/parser/golang_test.go @@ -1,4 +1,4 @@ -package generate_test +package parser_test import ( "context" @@ -11,10 +11,11 @@ import ( "github.com/stretchr/testify/require" "github.com/kilianpaquier/craft/pkg/craft" - "github.com/kilianpaquier/craft/pkg/generate" + "github.com/kilianpaquier/craft/pkg/generate/parser" + generate "github.com/kilianpaquier/craft/pkg/generate/types" ) -func TestDetectGolang(t *testing.T) { +func TestGolang(t *testing.T) { ctx := context.Background() t.Run("no_gomod", func(t *testing.T) { @@ -22,11 +23,10 @@ func TestDetectGolang(t *testing.T) { config := generate.Metadata{} // Act - exec, err := generate.DetectGolang(ctx, "", &config) + _, err := parser.Golang(ctx, "", &config) // Assert require.NoError(t, err) - assert.Empty(t, exec) assert.Zero(t, config) }) @@ -41,11 +41,10 @@ func TestDetectGolang(t *testing.T) { config := generate.Metadata{} // Act - exec, err := generate.DetectGolang(ctx, destdir, &config) + _, err = parser.Golang(ctx, destdir, &config) // Assert assert.ErrorContains(t, err, "read go.mod") - assert.Empty(t, exec) assert.Zero(t, config) }) @@ -60,13 +59,11 @@ func TestDetectGolang(t *testing.T) { config := generate.Metadata{} // Act - exec, err := generate.DetectGolang(ctx, destdir, &config) + _, err = parser.Golang(ctx, destdir, &config) // Assert - assert.ErrorContains(t, err, "read go.mod") - assert.ErrorContains(t, err, "invalid go.mod, module statement is missing") - assert.ErrorContains(t, err, "invalid go.mod, go statement is missing") - assert.Empty(t, exec) + assert.ErrorIs(t, err, parser.ErrMissingGoStatement) + assert.ErrorIs(t, err, parser.ErrMissingModuleStatement) assert.Zero(t, config) }) @@ -86,7 +83,7 @@ func TestDetectGolang(t *testing.T) { expected := generate.Metadata{ Configuration: craft.Configuration{Platform: craft.GitHub}, Languages: map[string]any{ - "golang": generate.Gomod{ + "golang": parser.Gomod{ LangVersion: "1.22", Platform: craft.GitHub, ProjectHost: "github.com", @@ -100,11 +97,10 @@ func TestDetectGolang(t *testing.T) { } // Act - exec, err := generate.DetectGolang(ctx, destdir, &config) + _, err = parser.Golang(ctx, destdir, &config) // Assert require.NoError(t, err) - assert.Len(t, exec, 1) assert.Equal(t, expected, config) }) @@ -125,12 +121,10 @@ func TestDetectGolang(t *testing.T) { t.Cleanup(func() { assert.NoError(t, hugo.Close()) }) config := generate.Metadata{ - Configuration: craft.Configuration{CI: &craft.CI{Options: []string{craft.CodeCov, craft.CodeQL, craft.Sonar}}}, - Languages: map[string]any{}, + Languages: map[string]any{}, } expected := generate.Metadata{ Configuration: craft.Configuration{ - CI: &craft.CI{Options: []string{}}, Platform: craft.GitHub, }, Languages: map[string]any{"hugo": nil}, @@ -140,11 +134,10 @@ func TestDetectGolang(t *testing.T) { } // Act - exec, err := generate.DetectGolang(ctx, destdir, &config) + _, err = parser.Golang(ctx, destdir, &config) // Assert require.NoError(t, err) - assert.Len(t, exec, 1) assert.Equal(t, expected, config) }) @@ -187,7 +180,7 @@ func TestDetectGolang(t *testing.T) { Crons: map[string]struct{}{"cron-name": {}}, Jobs: map[string]struct{}{"job-name": {}}, Languages: map[string]any{ - "golang": generate.Gomod{ + "golang": parser.Gomod{ LangVersion: "1.22.2", Platform: craft.GitHub, ProjectHost: "github.com", @@ -202,11 +195,10 @@ func TestDetectGolang(t *testing.T) { } // Act - exec, err := generate.DetectGolang(ctx, destdir, &config) + _, err = parser.Golang(ctx, destdir, &config) // Assert require.NoError(t, err) - assert.Len(t, exec, 1) assert.Equal(t, expected, config) }) } diff --git a/pkg/generate/parser/helm.go b/pkg/generate/parser/helm.go new file mode 100644 index 00000000..0c8e8b38 --- /dev/null +++ b/pkg/generate/parser/helm.go @@ -0,0 +1,50 @@ +package parser + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io/fs" + "os" + "path/filepath" + + "dario.cat/mergo" + + "github.com/kilianpaquier/craft/pkg/craft" + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +// Helm parses helm partin destdir repository. +func Helm(_ context.Context, destdir string, metadata *generate.Metadata) ([]handler.Handler, error) { + chartdir := filepath.Join(destdir, "chart") + if metadata.NoChart { + if err := os.RemoveAll(chartdir); err != nil { + return nil, fmt.Errorf("remove chart dir: %w", err) + } + return nil, nil + } + log.Infof("helm chart detected, %s doesn't have no_chart key", craft.File) + + // transform craft configuration into generic chart configuration (easier to maintain) + var chart map[string]any + bytes, _ := json.Marshal(metadata) + _ = json.Unmarshal(bytes, &chart) + + // read overrides values + var overrides map[string]any + if err := craft.Read(chartdir, &overrides); err != nil && !errors.Is(err, fs.ErrNotExist) { + return nil, fmt.Errorf("read helm chart overrides: %w", err) + } + + // merge overrides into chart with overwrite + if err := mergo.Merge(&chart, overrides, mergo.WithOverride); err != nil { + return nil, fmt.Errorf("merge helm chart overrides with craft configuration: %w", err) + } + + metadata.Languages["helm"] = chart + return nil, nil +} + +var _ Parser = Helm // ensure interface is implemented diff --git a/pkg/generate/parser/helm_test.go b/pkg/generate/parser/helm_test.go new file mode 100644 index 00000000..d3f89a42 --- /dev/null +++ b/pkg/generate/parser/helm_test.go @@ -0,0 +1,99 @@ +package parser_test + +import ( + "context" + "os" + "path/filepath" + "testing" + + "github.com/kilianpaquier/cli-sdk/pkg/cfs" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/kilianpaquier/craft/internal/helpers" + "github.com/kilianpaquier/craft/pkg/craft" + "github.com/kilianpaquier/craft/pkg/generate/parser" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +func TestHelm(t *testing.T) { + ctx := context.Background() + + noChart := &generate.Metadata{Configuration: craft.Configuration{NoChart: true}} + + t.Run("success_remove_no_chart_dir", func(t *testing.T) { + // Arrange + destdir := t.TempDir() + chart := filepath.Join(destdir, "chart") + + // Act + _, err := parser.Helm(ctx, destdir, noChart) + + // Assert + require.NoError(t, err) + assert.NoDirExists(t, chart) + }) + + t.Run("success_remove_chart_dir", func(t *testing.T) { + // Arrange + destdir := t.TempDir() + chart := filepath.Join(destdir, "chart") + require.NoError(t, os.Mkdir(chart, cfs.RwxRxRxRx)) + + // Act + _, err := parser.Helm(ctx, destdir, noChart) + + // Assert + require.NoError(t, err) + assert.NoDirExists(t, chart) + }) + + t.Run("error_invalid_overrides", func(t *testing.T) { + // Arrange + destdir := t.TempDir() + overrides := filepath.Join(destdir, "chart", craft.File) + require.NoError(t, os.MkdirAll(overrides, cfs.RwxRxRxRx)) + + // Act + _, err := parser.Helm(ctx, destdir, &generate.Metadata{}) + + // Assert + assert.ErrorContains(t, err, "read helm chart overrides") + }) + + t.Run("success_merge_overrides", func(t *testing.T) { + // Arrange + destdir := t.TempDir() + chartdir := filepath.Join(destdir, "chart") + require.NoError(t, os.MkdirAll(chartdir, cfs.RwxRxRxRx)) + err := os.WriteFile(filepath.Join(chartdir, craft.File), []byte("description: some description for testing purposes"), cfs.RwRR) + require.NoError(t, err) + + config := generate.Metadata{ + Languages: map[string]any{}, + Clis: map[string]struct{}{"cli-name": {}}, + Configuration: craft.Configuration{ + Docker: &craft.Docker{Port: helpers.ToPtr(uint16(5000))}, + }, + Crons: map[string]struct{}{"cron-name": {}}, + Jobs: map[string]struct{}{"job-name": {}}, + Workers: map[string]struct{}{"worker-name": {}}, + } + expected := map[string]any{ + "crons": map[string]any{"cron-name": map[string]any{}}, + "description": "some description for testing purposes", + "docker": map[string]any{"port": 5000.}, + "jobs": map[string]any{"job-name": map[string]any{}}, + "workers": map[string]any{"worker-name": map[string]any{}}, + } + + // Act + _, err = parser.Helm(ctx, destdir, &config) + + // Assert + require.NoError(t, err) + values, ok := config.Languages["helm"] + require.True(t, ok) + assert.Equal(t, expected, values) + }) +} diff --git a/pkg/generate/parser/license.go b/pkg/generate/parser/license.go new file mode 100644 index 00000000..786adf5a --- /dev/null +++ b/pkg/generate/parser/license.go @@ -0,0 +1,87 @@ +package parser + +import ( + "context" + "errors" + "fmt" + "io/fs" + "net/http" + "os" + "path/filepath" + + "github.com/hashicorp/go-cleanhttp" + "github.com/kilianpaquier/cli-sdk/pkg/cfs" + "github.com/xanzy/go-gitlab" + + "github.com/kilianpaquier/craft/pkg/craft" + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +const ( + // GitLabURL is the default GitLab API URL. + GitLabURL = "https://gitlab.com/api/v4" + + // GitHubURL is the default GitHub API URL. + GitHubURL = "https://api.github.com" +) + +// httpClient is the default http.Client to make requests overs HTTP(s) in craft. +var httpClient = cleanhttp.DefaultClient() + +// SetHTTPClient sets the global craft http.Client only if the input one is not nil. +func SetHTTPClient(client *http.Client) { + if client != nil { + httpClient = client + } +} + +// License generates the LICENSE file in case input configuration asks for a LICENSE file. +func License(ctx context.Context, destdir string, metadata *generate.Metadata) ([]handler.Handler, error) { + dest := filepath.Join(destdir, craft.License) + if metadata.License == nil { + if err := os.Remove(dest); err != nil && !errors.Is(err, fs.ErrNotExist) { + return nil, fmt.Errorf("remove '%s': %w", craft.License, err) + } + return nil, nil + } + log.Infof("license detected, %s has license key", craft.File) + + // don't do anything if the LICENSE file already exists + if cfs.Exists(dest) { + return nil, nil + } + + // initialize gitlab client + client, err := gitlab.NewClient(os.Getenv("GITLAB_TOKEN"), + gitlab.WithBaseURL(GitLabURL), + gitlab.WithHTTPClient(httpClient), + gitlab.WithoutRetries(), + gitlab.WithRequestOptions(gitlab.WithContext(ctx))) + if err != nil { + // should never happen since it's gitlab.ClientOptionFunc that are throwing errors + // and currently WithBaseURL with fixed URL + // and WithoutRetries won't throw errors + // but in any case err must be handled in case it evolves or other options are added + log.Warnf("failed to initialize gitlab client in license detection, skipping license generation: %s", err.Error()) + return nil, nil + } + + // fetch license template + options := &gitlab.GetLicenseTemplateOptions{ + Fullname: &metadata.Maintainers[0].Name, + Project: &metadata.ProjectName, + } + license, _, err := client.LicenseTemplates.GetLicenseTemplate(*metadata.License, options, gitlab.WithContext(ctx)) + if err != nil { + return nil, fmt.Errorf("get license template '%s': %w", *metadata.License, err) + } + + // write license template + if err := os.WriteFile(dest, []byte(license.Content), cfs.RwRR); err != nil { + return nil, fmt.Errorf("write license file: %w", err) + } + return nil, nil +} + +var _ Parser = License // ensure interface is implemented diff --git a/pkg/generate/parser/license_test.go b/pkg/generate/parser/license_test.go new file mode 100644 index 00000000..2b639b91 --- /dev/null +++ b/pkg/generate/parser/license_test.go @@ -0,0 +1,151 @@ +package parser_test + +import ( + "context" + "net/http" + "os" + "path/filepath" + "testing" + + "github.com/hashicorp/go-cleanhttp" + "github.com/jarcoal/httpmock" + "github.com/kilianpaquier/cli-sdk/pkg/cfs" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/xanzy/go-gitlab" + + "github.com/kilianpaquier/craft/internal/helpers" + "github.com/kilianpaquier/craft/pkg/craft" + "github.com/kilianpaquier/craft/pkg/generate/parser" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +func TestLicense(t *testing.T) { + ctx := context.Background() + + httpClient := cleanhttp.DefaultClient() + httpmock.ActivateNonDefault(httpClient) + t.Cleanup(httpmock.DeactivateAndReset) + + parser.SetHTTPClient(httpClient) + t.Cleanup(func() { parser.SetHTTPClient(cleanhttp.DefaultClient()) }) + + url := parser.GitLabURL + "/templates/licenses/mit" + + t.Run("error_remove_license", func(t *testing.T) { + // Arrange + destdir := t.TempDir() + dest := filepath.Join(destdir, craft.License) + require.NoError(t, os.MkdirAll(filepath.Join(dest, "file.txt"), cfs.RwxRxRxRx)) + + // Act + _, err := parser.License(ctx, destdir, &generate.Metadata{}) + + // Assert + assert.ErrorContains(t, err, "remove 'LICENSE'") + }) + + t.Run("success_remove_no_license", func(t *testing.T) { + // Arrange + destdir := t.TempDir() + dest := filepath.Join(destdir, craft.License) + + // Act + _, err := parser.License(ctx, destdir, &generate.Metadata{}) + + // Assert + require.NoError(t, err) + assert.NoFileExists(t, dest) + }) + + t.Run("success_remove_license", func(t *testing.T) { + // Arrange + destdir := t.TempDir() + dest := filepath.Join(destdir, craft.License) + file, err := os.Create(dest) + require.NoError(t, err) + require.NoError(t, file.Close()) + + // Act + _, err = parser.License(ctx, destdir, &generate.Metadata{}) + + // Assert + require.NoError(t, err) + assert.NoFileExists(t, dest) + }) + + t.Run("error_get_templates", func(t *testing.T) { + // Arrange + t.Cleanup(httpmock.Reset) + httpmock.RegisterResponder(http.MethodGet, url, + httpmock.NewStringResponder(http.StatusInternalServerError, "error message")) + + destdir := t.TempDir() + config := generate.Metadata{ + Configuration: craft.Configuration{ + License: helpers.ToPtr("mit"), + Maintainers: []*craft.Maintainer{{Name: "name"}}, + }, + ProjectName: "craft", + } + + // Act + _, err := parser.License(ctx, destdir, &config) + + // Assert + assert.ErrorContains(t, err, "get license template 'mit'") + assert.ErrorContains(t, err, "error message") + }) + + t.Run("success_download_license", func(t *testing.T) { + // Arrange + t.Cleanup(httpmock.Reset) + httpmock.RegisterResponder(http.MethodGet, url, + httpmock.NewJsonResponderOrPanic(http.StatusOK, gitlab.LicenseTemplate{Content: "some content to appear in assert"})) + + destdir := t.TempDir() + dest := filepath.Join(destdir, craft.License) + + config := generate.Metadata{ + Configuration: craft.Configuration{ + License: helpers.ToPtr("mit"), + Maintainers: []*craft.Maintainer{{Name: "name"}}, + }, + ProjectName: "craft", + } + + // Act + _, err := parser.License(ctx, destdir, &config) + + // Assert + require.NoError(t, err) + bytes, err := os.ReadFile(dest) + require.NoError(t, err) + assert.Equal(t, "some content to appear in assert", string(bytes)) + assert.Equal(t, 1, httpmock.GetTotalCallCount()) + }) + + t.Run("success_license_already_exists", func(t *testing.T) { + // Arrange + destdir := t.TempDir() + dest := filepath.Join(destdir, craft.License) + file, err := os.Create(dest) + require.NoError(t, err) + require.NoError(t, file.Close()) + + config := generate.Metadata{ + Configuration: craft.Configuration{ + License: helpers.ToPtr("mit"), + Maintainers: []*craft.Maintainer{{Name: "name"}}, + }, + ProjectName: "craft", + } + + // Act + _, err = parser.License(ctx, destdir, &config) + + // Assert + require.NoError(t, err) + assert.Equal(t, 0, httpmock.GetTotalCallCount()) + }) +} diff --git a/pkg/generate/nodejs.go b/pkg/generate/parser/node.go similarity index 74% rename from pkg/generate/nodejs.go rename to pkg/generate/parser/node.go index a12dc57d..ab56fdec 100644 --- a/pkg/generate/nodejs.go +++ b/pkg/generate/parser/node.go @@ -1,4 +1,4 @@ -package generate +package parser import ( "context" @@ -13,11 +13,17 @@ import ( "github.com/go-playground/validator/v10" "github.com/kilianpaquier/craft/pkg/craft" + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" ) var ( + // ErrInvalidStaticDeployment represents the returned error when static deployment is provided in craft configuration + // but current node project doesn't have a main file provided in package.json. ErrInvalidStaticDeployment = errors.New("package.json 'main' isn't provided but a static deployment is configured") - ErrMissingPackageManager = errors.New("package.json 'packageManager' isn't valid") + + // ErrInvalidPackageManager is the error returned when the packageManager is missing or invalid in package.json. + ErrInvalidPackageManager = errors.New("package.json 'packageManager' is missing or isn't valid") ) var packageManagerRegexp = regexp.MustCompile(`^(npm|pnpm|yarn|bun)@\d+\.\d+\.\d+(-.+)?$`) @@ -53,7 +59,7 @@ func (p *PackageJSON) Validate() error { if p.PackageManager != "" && !packageManagerRegexp.MatchString(p.PackageManager) { // json schema takes care of saying which regexp must be validated - errs = append(errs, ErrMissingPackageManager) + errs = append(errs, ErrInvalidPackageManager) } if err := validator.New().Struct(p); err != nil { @@ -62,9 +68,10 @@ func (p *PackageJSON) Validate() error { return errors.Join(errs...) } -// DetectNodejs handles nodejs detection at destdir. +// Node handles node repository parsing at destdir. +// // It scans the project for a package.json and validates it. -func DetectNodejs(_ context.Context, destdir string, metadata *Metadata) ([]ExecFunc, error) { +func Node(_ context.Context, destdir string, metadata *generate.Metadata) ([]handler.Handler, error) { jsonpath := filepath.Join(destdir, craft.PackageJSON) pkg, err := readPackageJSON(jsonpath) if err != nil { @@ -74,28 +81,20 @@ func DetectNodejs(_ context.Context, destdir string, metadata *Metadata) ([]Exec return nil, nil } - log.Infof("nodejs detected, a '%s' is present and valid", craft.PackageJSON) + log.Infof("node detected, a '%s' is present and valid", craft.PackageJSON) - metadata.Languages["nodejs"] = pkg + metadata.Languages["node"] = pkg metadata.ProjectName = pkg.Name if pkg.Main != nil { metadata.Binaries++ - } else if metadata.CI != nil && metadata.CI.Static != nil { - return nil, ErrInvalidStaticDeployment - } - - // deactivate makefile because commands are facilitated by package.json scripts - if !metadata.NoMakefile { - log.Warnf("makefile option not available with nodejs generation, deactivating it") - metadata.NoMakefile = true } - - return []ExecFunc{BasicExecFunc("lang_nodejs")}, nil + return nil, nil } -var _ DetectFunc = DetectNodejs // ensure interface is implemented +var _ Parser = Node // ensure interface is implemented -// readPackageJSON reads the package.json provided at input jsonpath. It returns any error encountered. +// readPackageJSON reads the package.json provided at input jsonpath. +// It returns any error encountered. func readPackageJSON(jsonpath string) (PackageJSON, error) { bytes, err := os.ReadFile(jsonpath) if err != nil { diff --git a/pkg/generate/nodejs_test.go b/pkg/generate/parser/node_test.go similarity index 55% rename from pkg/generate/nodejs_test.go rename to pkg/generate/parser/node_test.go index 2e17905b..c60a9528 100644 --- a/pkg/generate/nodejs_test.go +++ b/pkg/generate/parser/node_test.go @@ -1,4 +1,4 @@ -package generate_test +package parser_test import ( "context" @@ -12,19 +12,19 @@ import ( "github.com/kilianpaquier/craft/internal/helpers" "github.com/kilianpaquier/craft/pkg/craft" - "github.com/kilianpaquier/craft/pkg/generate" + "github.com/kilianpaquier/craft/pkg/generate/parser" + generate "github.com/kilianpaquier/craft/pkg/generate/types" ) -func TestDetectNodejs(t *testing.T) { +func TestNode(t *testing.T) { ctx := context.Background() t.Run("no_packagejson", func(t *testing.T) { // Act - exec, err := generate.DetectNodejs(ctx, "", &generate.Metadata{}) + _, err := parser.Node(ctx, "", &generate.Metadata{}) // Assert require.NoError(t, err) - assert.Empty(t, exec) }) t.Run("invalid_packagejson", func(t *testing.T) { @@ -37,11 +37,10 @@ func TestDetectNodejs(t *testing.T) { require.NoError(t, file.Close()) // Act - exec, err := generate.DetectNodejs(ctx, destdir, &generate.Metadata{}) + _, err = parser.Node(ctx, destdir, &generate.Metadata{}) // Assert assert.ErrorContains(t, err, "read package.json") - assert.Empty(t, exec) }) t.Run("error_validation_packageManager", func(t *testing.T) { @@ -53,37 +52,13 @@ func TestDetectNodejs(t *testing.T) { require.NoError(t, err) // Act - exec, err := generate.DetectNodejs(ctx, destdir, &generate.Metadata{}) + _, err = parser.Node(ctx, destdir, &generate.Metadata{}) // Assert - assert.ErrorIs(t, err, generate.ErrMissingPackageManager) - assert.Empty(t, exec) + assert.ErrorIs(t, err, parser.ErrInvalidPackageManager) }) - t.Run("error_invalid_static_option", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - - packagejson := filepath.Join(destdir, craft.PackageJSON) - err := os.WriteFile(packagejson, []byte(`{ "name": "craft", "packageManager": "bun@1.1.6", "private": true }`), cfs.RwRR) - require.NoError(t, err) - - config := generate.Metadata{ - Configuration: craft.Configuration{ - CI: &craft.CI{Static: &craft.Static{}}, - }, - Languages: map[string]any{}, - } - - // Act - exec, err := generate.DetectNodejs(ctx, destdir, &config) - - // Assert - assert.ErrorIs(t, err, generate.ErrInvalidStaticDeployment) - assert.Empty(t, exec) - }) - - t.Run("nodejs_detected_with_options", func(t *testing.T) { + t.Run("node_detected_with_options", func(t *testing.T) { // Arrange destdir := t.TempDir() @@ -93,10 +68,9 @@ func TestDetectNodejs(t *testing.T) { config := generate.Metadata{Languages: map[string]any{}} expected := generate.Metadata{ - Binaries: 1, - Configuration: craft.Configuration{NoMakefile: true}, + Binaries: 1, Languages: map[string]any{ - "nodejs": generate.PackageJSON{ + "node": parser.PackageJSON{ Main: helpers.ToPtr("index.js"), Name: "craft", PackageManager: "bun@1.1.6", @@ -107,11 +81,10 @@ func TestDetectNodejs(t *testing.T) { } // Act - exec, err := generate.DetectNodejs(ctx, destdir, &config) + _, err = parser.Node(ctx, destdir, &config) // Assert require.NoError(t, err) - assert.Len(t, exec, 1) assert.Equal(t, expected, config) }) } diff --git a/pkg/generate/parser/parser.go b/pkg/generate/parser/parser.go new file mode 100644 index 00000000..111382ff --- /dev/null +++ b/pkg/generate/parser/parser.go @@ -0,0 +1,45 @@ +package parser + +import ( + "context" + + "github.com/kilianpaquier/cli-sdk/pkg/clog" + + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +var log clog.Logger = clog.Noop() + +// SetLogger sets the global logger for parser package. +// +// In case the input logger is nil, then nothing is done to avoid panics. +func SetLogger(input clog.Logger) { + if input != nil { + log = input + } +} + +// Parser is the function to parse a specific part of destdir repository. +// +// It returns a slice of Handlers according to which templates files should be generated +// and with which specificities. +type Parser func(ctx context.Context, destdir string, metadata *generate.Metadata) ([]handler.Handler, error) + +// Defaults returns the slice of implemented parsers in craft SDK. +// +// It will be used in case WithParsers option is not given in Run function. +func Defaults() []Parser { + return []Parser{ + // parse git repository first + Git, + + License, // parse license configuration in configuration and generate it + Golang, // parse go.mod + Node, // parse package.json + Helm, // parse helm configuration and overrides + + // return all standard handlers (must be last) + Standard, + } +} diff --git a/pkg/generate/parser/parser_test.go b/pkg/generate/parser/parser_test.go new file mode 100644 index 00000000..459ffef2 --- /dev/null +++ b/pkg/generate/parser/parser_test.go @@ -0,0 +1,33 @@ +package parser_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/kilianpaquier/craft/pkg/generate/parser" +) + +func TestDefaultParsers(t *testing.T) { + t.Run("success", func(t *testing.T) { + // Assert + expected := []parser.Parser{ + // parse git repository first + parser.Git, + + parser.License, // parse license configuration in configuration and generate it + parser.Golang, // parse go.mod + parser.Node, // parse package.json + parser.Helm, // parse helm configuration and overrides + + // return all standard handlers (must be last) + parser.Standard, + } + + // Act + parsers := parser.Defaults() + + // Assert + assert.Len(t, parsers, len(expected)) // can't compare functions between them + }) +} diff --git a/pkg/generate/parser/standard.go b/pkg/generate/parser/standard.go new file mode 100644 index 00000000..86c94a13 --- /dev/null +++ b/pkg/generate/parser/standard.go @@ -0,0 +1,23 @@ +package parser + +import ( + "context" + "errors" + + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +// ErrNilMetadata is returned when a given function takes nil for metadata property. +var ErrNilMetadata = errors.New("invalid metadata input, it shouldn't be nil") + +// Standard isn't really a parser, but it does return all default craft SDK handlers +// after metadata enrichment with all parsers results. +func Standard(_ context.Context, _ string, metadata *generate.Metadata) ([]handler.Handler, error) { + if metadata == nil { + return nil, ErrNilMetadata + } + return handler.Defaults(*metadata), nil +} + +var _ Parser = Standard // ensure interface is implemented diff --git a/pkg/generate/parser/standard_test.go b/pkg/generate/parser/standard_test.go new file mode 100644 index 00000000..ce679dfa --- /dev/null +++ b/pkg/generate/parser/standard_test.go @@ -0,0 +1,33 @@ +package parser_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/kilianpaquier/craft/pkg/generate/parser" + generate "github.com/kilianpaquier/craft/pkg/generate/types" +) + +func TestStandard(t *testing.T) { + ctx := context.Background() + + t.Run("error_nil_metadata", func(t *testing.T) { + // Act + _, err := parser.Standard(ctx, "", nil) + + // Assert + assert.ErrorIs(t, err, parser.ErrNilMetadata) + }) + + t.Run("success", func(t *testing.T) { + // Act + handlers, err := parser.Standard(ctx, "", &generate.Metadata{}) + + // Assert + require.NoError(t, err) + assert.Len(t, handlers, 13) + }) +} diff --git a/pkg/generate/remote_test.go b/pkg/generate/remote_test.go deleted file mode 100644 index b02b8b93..00000000 --- a/pkg/generate/remote_test.go +++ /dev/null @@ -1,155 +0,0 @@ -package generate_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/kilianpaquier/craft/pkg/craft" - "github.com/kilianpaquier/craft/pkg/generate" -) - -func TestOriginURL(t *testing.T) { - t.Run("empty_no_git", func(t *testing.T) { - // Arrange - destdir := t.TempDir() - - // Act - originURL, err := generate.OriginURL(destdir) - - // Assert - assert.ErrorContains(t, err, "retrieve remote url") - assert.Empty(t, originURL) - }) - - t.Run("valid_git_repository", func(t *testing.T) { - // Act - originURL, err := generate.OriginURL(".") - - // Assert - require.NoError(t, err) - assert.Contains(t, originURL, "kilianpaquier/craft") // contains condition to ensure it's working on github actions too - }) -} - -func TestParseRemote(t *testing.T) { - t.Run("empty_remote", func(t *testing.T) { - // Act - host, subpath := generate.ParseRemote("") - - // Assert - assert.Empty(t, host) - assert.Empty(t, subpath) - }) - - t.Run("parse_ssh_remote", func(t *testing.T) { - // Arrange - rawRemote := "git@github.com:kilianpaquier/craft.git" - - // Act - host, subpath := generate.ParseRemote(rawRemote) - - // Assert - assert.Equal(t, "github.com", host) - assert.Equal(t, "kilianpaquier/craft", subpath) - }) - - t.Run("parse_http_remote", func(t *testing.T) { - // Arrange - rawRemote := "https://github.com/kilianpaquier/craft.git" - - // Act - host, subpath := generate.ParseRemote(rawRemote) - - // Assert - assert.Equal(t, "github.com", host) - assert.Equal(t, "kilianpaquier/craft", subpath) - }) -} - -func TestParsePlatform(t *testing.T) { - t.Run("not_found_unknown_host", func(t *testing.T) { - // Arrange - host := "entreprise.onpremise.gitsome.org" - - // Act - platform, ok := generate.ParsePlatform(host) - - // Assert - assert.False(t, ok) - assert.Empty(t, platform) - }) - - t.Run("found_bitbucket", func(t *testing.T) { - // Arrange - host := "bitbucket.org" - - // Act - platform, ok := generate.ParsePlatform(host) - - // Assert - assert.True(t, ok) - assert.Equal(t, craft.Bitbucket, platform) - }) - - t.Run("found_stash", func(t *testing.T) { - // Arrange - host := "stash.example.com" - - // Act - platform, ok := generate.ParsePlatform(host) - - // Assert - assert.True(t, ok) - assert.Equal(t, craft.Bitbucket, platform) - }) - - t.Run("found_gitea", func(t *testing.T) { - // Arrange - host := "gitea.org" - - // Act - platform, ok := generate.ParsePlatform(host) - - // Assert - assert.True(t, ok) - assert.Equal(t, craft.Gitea, platform) - }) - - t.Run("found_github", func(t *testing.T) { - // Arrange - host := "github.com" - - // Act - platform, ok := generate.ParsePlatform(host) - - // Assert - assert.True(t, ok) - assert.Equal(t, craft.GitHub, platform) - }) - - t.Run("found_gitlab", func(t *testing.T) { - // Arrange - host := "gitlab.com" - - // Act - platform, ok := generate.ParsePlatform(host) - - // Assert - assert.True(t, ok) - assert.Equal(t, craft.GitLab, platform) - }) - - t.Run("found_gitlab_onpremise", func(t *testing.T) { - // Arrange - host := "gitlab.entreprise.com" - - // Act - platform, ok := generate.ParsePlatform(host) - - // Assert - assert.True(t, ok) - assert.Equal(t, craft.GitLab, platform) - }) -} diff --git a/pkg/generate/run.go b/pkg/generate/run.go index 35797982..4e320ae2 100644 --- a/pkg/generate/run.go +++ b/pkg/generate/run.go @@ -2,187 +2,130 @@ package generate import ( "context" - "embed" "errors" + "fmt" + "io/fs" + "os" "path" - "sync" + "path/filepath" + "strings" + "text/template" + "github.com/Masterminds/sprig/v3" "github.com/kilianpaquier/cli-sdk/pkg/cfs" - "github.com/kilianpaquier/cli-sdk/pkg/clog" "github.com/kilianpaquier/craft/pkg/craft" + "github.com/kilianpaquier/craft/pkg/generate/handler" + generate "github.com/kilianpaquier/craft/pkg/generate/types" + "github.com/kilianpaquier/craft/pkg/templating" ) -// ErrMultipleLanguages is the error returned when multiple languages are matched during detection since craft doesn't handle this case yet. -var ErrMultipleLanguages = errors.New("multiple languages detected, please open an issue since it's not confirmed to be working flawlessly yet") - -//go:embed all:templates -var tmpl embed.FS - -var _ cfs.FS = (*embed.FS)(nil) // ensure interface is implemented - -// FS returns the default fs (embedded) used by craft when not extended as a SDK. -func FS() cfs.FS { - return tmpl -} - -var log clog.Logger = clog.Noop() - -// SetLogger sets the logger for all default features (DetectFuncs and ExecFuncs) offered by craft as a SDK. -func SetLogger(input clog.Logger) { - if input != nil { - log = input - } -} - -// DetectFunc is the signature function to implement to add a new language or framework detection in craft. -// -// The input configuration can be altered in any way since it's a pointer -// and the returned slice of ExecFunc will be run by the main Run function of generate package. -type DetectFunc func(ctx context.Context, destdir string, metadata *Metadata) ([]ExecFunc, error) - -// DetectFuncs returns the slice of default detection functions when craft is not used as a SDK. -// -// Note that DetectGeneric must always be the last one to be computed -// since it's a fallback to be used in case no languages are detected. -func DetectFuncs() []DetectFunc { - return []DetectFunc{DetectGolang, DetectHelm, DetectLicense, DetectNodejs, DetectGeneric} -} - -// ExecFunc is the signature function to implement to add a new language or framework generation in craft. -// -// An ExecFunc function is to be returned by its associated DetectFunc function. -// For more information about DetectFunc type, see its documentation. -type ExecFunc func(ctx context.Context, fsys cfs.FS, srcdir, destdir string, metadata Metadata, opts ExecOpts) error - -// Metadata represents all properties available for enrichment during detection. -// -// Those additional properties will be enriched during generate execution and project parsing. -// They will be used for files and helm chart templating (if applicable). -type Metadata struct { - craft.Configuration - - // Languages is a map of language name with its specificities. - // - // For instance for nodejs, with default DetectNodejs it would contain an element "nodejs" with PackageJSON struct. - // For instance for golang, with default DetectGolang it would contain an element "golang" with Gomod struct. - Languages map[string]any `json:"-"` - - // ProjectHost represents the host where the project is hosted. - // - // As craft only handles git, it would be an host like github.com, gitlab.com, bitbucket.org, etc. - // Of course it can also be a private host like github.company.com. It will depend on the git origin URL or for golang the host of module name. - ProjectHost string `json:"projectHost"` - - // ProjectName is the project name being generated. - // By default with Run function, it will be the base path of ParseRemote's subpath result following OriginURL result. - ProjectName string `json:"projectName,omitempty"` - - // ProjectPath is the project path. - // By default with Run function, it will be the subpath in ParseRemote result. - ProjectPath string `json:"projectPath"` - - // Binaries is the total number of binaries / executables parsed during craft execution. - // It's especially used for golang generation (with workers, cronjob, jobs, etc.) - // but also in nodejs generation in case a "main" property is present in package.json. - Binaries uint8 `json:"-"` - - // Clis is a map of CLI names without value (empty struct). It can be populated by DetectFunc functions. - Clis map[string]struct{} `json:"-"` - - // Crons is a map of cronjob names without value (empty struct). It can be populated by DetectFunc functions. - Crons map[string]struct{} `json:"crons,omitempty"` - - // Jobs is a map of job names without value (empty struct). It can be populated by DetectFunc functions. - Jobs map[string]struct{} `json:"jobs,omitempty"` - - // Workers is a map of workers names without value (empty struct). It can be populated by DetectFunc functions. - Workers map[string]struct{} `json:"workers,omitempty"` -} - -// Run is the main function for this package generate. +// Run is the main function from generate package. +// It takes a craft configuration and various run options. // -// It's a flexible function to run to generate a project layout depending on various behaviors (MetaHandler and FileHandler) -// and various detections (DetectFunc). -// -// As a DetectFunc function can alter the configuration, the final configuration is returned alongside any encountered error. +// It executes all parsers given in options (or default ones) +// and then dives into all directories from option filesystem (or default one) +// to generates template files (.tmpl) specified by the handlers returned from parsers. func Run(ctx context.Context, config craft.Configuration, opts ...RunOption) (craft.Configuration, error) { ro := newRunOpt(opts...) - - // parse remote information - rawRemote, err := OriginURL(*ro.destdir) - if err != nil { - log.Warnf("failed to retrieve git remote.origin.url: %s", err.Error()) + meta := generate.Metadata{ + Configuration: config, + Languages: map[string]any{}, + Clis: map[string]struct{}{}, + Crons: map[string]struct{}{}, + Jobs: map[string]struct{}{}, + Workers: map[string]struct{}{}, } - host, subpath := ParseRemote(rawRemote) - if config.Platform == "" { - config.Platform, _ = ParsePlatform(host) - } + errs := make([]error, 0, len(ro.parsers)) + handlers := make([]handler.Handler, 0, len(ro.parsers)) // pre-alloc a approximative cap for handlers + for _, parser := range ro.parsers { + if parser == nil { + continue + } - props := Metadata{ - Configuration: config, + h, err := parser(ctx, *ro.destdir, &meta) + errs = append(errs, err) + handlers = append(handlers, h...) + } + if err := errors.Join(errs...); err != nil { + return meta.Configuration, err + } - Languages: map[string]any{}, + err := handleDir(ro.fs, ro.tmplDir, *ro.destdir, meta, handlers) + return meta.Configuration, err +} - ProjectHost: host, - ProjectName: path.Base(subpath), - ProjectPath: subpath, +func handleDir(fsys cfs.FS, srcdir, destdir string, data any, handlers []handler.Handler) error { + entries, err := fsys.ReadDir(srcdir) + if err != nil { + return fmt.Errorf("read directory: %w", err) + } - Clis: map[string]struct{}{}, - Crons: map[string]struct{}{}, - Jobs: map[string]struct{}{}, - Workers: map[string]struct{}{}, + errs := make([]error, 0, len(entries)) + for _, entry := range entries { + src := path.Join(srcdir, entry.Name()) + dest := filepath.Join(destdir, entry.Name()) + + // handler directories + if entry.IsDir() { + errs = append(errs, handleDir(fsys, src, dest, data, handlers)) // NOTE should handlers also tune directories generation ? + continue + } + + // handle files + if !strings.HasSuffix(src, craft.TmplExtension) || // ignore NOT suffixed files with .tmpl + strings.HasSuffix(src, craft.PartExtension+craft.TmplExtension) || // ignore suffixed files with .part.tmpl + strings.HasSuffix(src, craft.PatchExtension+craft.TmplExtension) { // ignore suffixed files with .patch.tmpl + continue //nolint:whitespace + } + + dest = strings.TrimSuffix(dest, craft.TmplExtension) + errs = append(errs, handleFile(fsys, src, dest, data, handlers)) } + return errors.Join(errs...) +} - // initialize a slice of errors to stack in each main step (detection, execution) errors - var errs []error //nolint:prealloc +func handleFile(fsys cfs.FS, src, dest string, data any, handlers []handler.Handler) error { + name := filepath.Base(dest) - // detect all available languages and specificities in current project - execs := make([]ExecFunc, 0, len(ro.detectFuncs)) - for _, f := range ro.detectFuncs { - exec, err := f(ctx, *ro.destdir, &props) - errs = append(errs, err) - execs = append(execs, exec...) + // find the right handler for current file + var ok bool + var result handler.Result + for _, h := range handlers { + if result, ok = h(src, dest, name); ok { + break + } } - if err := errors.Join(errs...); err != nil { - return props.Configuration, err + if !ok { + return nil // no handler defined for this file, skipping it } - // avoid multiple languages detected since no tests are made around that - if len(props.Languages) > 1 { - return props.Configuration, ErrMultipleLanguages + // remove file in case result is asking for + if result.Remove != nil && result.Remove() { + if err := os.RemoveAll(dest); err != nil && !errors.Is(err, fs.ErrNotExist) { + log.Warnf("failed to delete '%s': %s", name, err.Error()) + } + return nil } - eo := ExecOpts{ - EndDelim: ro.endDelim, - FileHandlers: func() []FileHandler { - result := make([]FileHandler, 0, len(ro.metaHandlers)) - for _, handler := range ro.metaHandlers { - result = append(result, handler(props)) - } - return result - }(), - Force: ro.force, - ForceAll: ro.forceAll, - StartDelim: ro.startDelim, + // avoid generating file if it already exists or something else + if result.Generate != nil && !result.Generate() { + log.Infof("not generating '%s' since it already exists", name) + return nil } - // initialize waitGroup for all executions and deletions - var wg sync.WaitGroup - wg.Add(len(execs)) - cerrs := make(chan error, len(execs)) - for _, f := range execs { - go func() { - defer wg.Done() - cerrs <- f(ctx, ro.fs, ro.tmplDir, *ro.destdir, props, eo) - }() + // template source file and generate it in target directory + tmpl, err := template.New(filepath.Base(src)). + Funcs(sprig.FuncMap()). + Funcs(templating.FuncMap()). + Delims(result.StartDelim, result.EndDelim). + ParseFS(fsys, result.Globs...) + if err != nil { + return fmt.Errorf("parse template file(s): %w", err) } - wg.Wait() - close(cerrs) - - for err := range cerrs { - errs = append(errs, err) + if err := templating.Execute(tmpl, data, dest); err != nil { + return fmt.Errorf("template execute: %w", err) } - return props.Configuration, errors.Join(errs...) + return nil } diff --git a/pkg/generate/run_option.go b/pkg/generate/run_option.go index 5a41a74c..8a07a32f 100644 --- a/pkg/generate/run_option.go +++ b/pkg/generate/run_option.go @@ -4,46 +4,26 @@ import ( "os" "github.com/kilianpaquier/cli-sdk/pkg/cfs" -) - -// ExecOpts represents all options given to ExecFunc functions. -type ExecOpts struct { - FileHandlers []FileHandler - - Force []string - ForceAll bool - EndDelim string - StartDelim string -} + "github.com/kilianpaquier/craft/pkg/generate/parser" +) // RunOption is the right function to tune Run function with specific behaviors. type RunOption func(runOptions) runOptions -// WithMetaHandlers is an option for Run function. -// It specifies the slice of MetaHandler, which defines the behavior for files and directories generation. +// WithParsers is an option for Run function. // -// When not given, MetaHandlers' function result is used as default slice. -func WithMetaHandlers(handlers ...MetaHandler) RunOption { - return func(o runOptions) runOptions { - o.metaHandlers = handlers - return o - } -} - -// WithDelimiters is an option for Run function to use specific go template delimiters. +// It specifies the slice of parsers, which defines how to parse the generated repository (languages parsing, license generation, defaults generation, etc.) // -// If not given, default delimiters are << and >>. -func WithDelimiters(startDelim, endDelim string) RunOption { +// When not given, default parsers will be used. +func WithParsers(parsers ...parser.Parser) RunOption { return func(o runOptions) runOptions { - o.startDelim = startDelim - o.endDelim = endDelim + o.parsers = parsers return o } } -// WithDestination is an option for Run function to specify -// the destination directory of generation. +// WithDestination is an option for Run function to specify the destination directory of generation. // // If not given, default destination is the current directory where Run is executed. func WithDestination(destdir string) RunOption { @@ -53,39 +33,6 @@ func WithDestination(destdir string) RunOption { } } -// WithDetects is an option for Run function defining the detections (languages) to identify. -// -// When not given, Detects is used as default slice. -func WithDetects(funcs ...DetectFunc) RunOption { - return func(o runOptions) runOptions { - o.detectFuncs = funcs - return o - } -} - -// WithForce is an option for Run function to specify which -// files must be generated even if the top notice is not present anymore (see IsGenerated). -// -// If not given, no files are force'd generated. -func WithForce(filenames ...string) RunOption { - return func(o runOptions) runOptions { - o.force = filenames - return o - } -} - -// WithForceAll is an option for Run function to specify -// whether to force the generation of all files or not. -// When given, WithForce isn't used. -// -// If not given, this option is false. -func WithForceAll(forceAll bool) RunOption { - return func(o runOptions) runOptions { - o.forceAll = forceAll - return o - } -} - // WithTemplates is an option for Run function to specify the templates directory and filesystem. // // Please not that the input dir path separator must be the one used with path.Join @@ -102,19 +49,12 @@ func WithTemplates(dir string, fs cfs.FS) RunOption { // runOptions is the struct related to Option function(s) defining all optional properties. type runOptions struct { - detectFuncs []DetectFunc - metaHandlers []MetaHandler + parsers []parser.Parser destdir *string - force []string - forceAll bool - fs cfs.FS tmplDir string - - endDelim string - startDelim string } // newRunOpt creates a new option struct with all input Option functions @@ -127,10 +67,6 @@ func newRunOpt(opts ...RunOption) runOptions { } } - if ro.startDelim == "" || ro.endDelim == "" { - ro.startDelim = "<<" - ro.endDelim = ">>" - } if ro.destdir == nil { dir, _ := os.Getwd() ro.destdir = &dir @@ -139,12 +75,8 @@ func newRunOpt(opts ...RunOption) runOptions { ro.fs = FS() ro.tmplDir = "templates" } - if len(ro.detectFuncs) == 0 { - ro.detectFuncs = DetectFuncs() + if len(ro.parsers) == 0 { + ro.parsers = parser.Defaults() } - if len(ro.metaHandlers) == 0 { - ro.metaHandlers = MetaHandlers() - } - return ro } diff --git a/pkg/generate/run_option_test.go b/pkg/generate/run_option_test.go index 026b4a6e..d05dba3c 100644 --- a/pkg/generate/run_option_test.go +++ b/pkg/generate/run_option_test.go @@ -1,56 +1,74 @@ package generate //nolint:testpackage import ( + "context" + "os" "testing" + "github.com/kilianpaquier/cli-sdk/pkg/cfs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/kilianpaquier/craft/pkg/generate/handler" + "github.com/kilianpaquier/craft/pkg/generate/parser" + generate "github.com/kilianpaquier/craft/pkg/generate/types" ) -func TestOption(t *testing.T) { - t.Run("success_delimiters", func(t *testing.T) { +func TestRunOption(t *testing.T) { + t.Run("success_destination", func(t *testing.T) { // Arrange - f := WithDelimiters("{{", "}}") + f := WithDestination("dest") // Act - o := f(runOptions{}) + ro := f(runOptions{}) // Assert - assert.Equal(t, "{{", o.startDelim) - assert.Equal(t, "}}", o.endDelim) + require.NotNil(t, ro.destdir) + assert.Equal(t, "dest", *ro.destdir) }) - t.Run("success_destination", func(t *testing.T) { + t.Run("success_parsers", func(t *testing.T) { // Arrange - f := WithDestination("dest") + f := WithParsers(func(_ context.Context, _ string, _ *generate.Metadata) ([]handler.Handler, error) { + return nil, nil + }) // Act - o := f(runOptions{}) + ro := f(runOptions{}) // Assert - require.NotNil(t, o.destdir) - assert.Equal(t, "dest", *o.destdir) + assert.Len(t, ro.parsers, 1) }) - t.Run("success_force", func(t *testing.T) { + t.Run("success_templates", func(t *testing.T) { // Arrange - f := WithForce("name") + f := WithTemplates("dir", cfs.OS()) // Act - o := f(runOptions{}) + ro := f(runOptions{}) // Assert - assert.Contains(t, o.force, "name") + assert.Equal(t, "dir", ro.tmplDir) + assert.Equal(t, cfs.OS(), ro.fs) }) - t.Run("success_forceall", func(t *testing.T) { + t.Run("success_defaults", func(t *testing.T) { // Arrange - f := WithForceAll(true) + pwd, _ := os.Getwd() + expected := runOptions{ + destdir: &pwd, + fs: FS(), + parsers: parser.Defaults(), + tmplDir: "templates", + } // Act - o := f(runOptions{}) + ro := newRunOpt() // Assert - assert.True(t, o.forceAll) + assert.Equal(t, *expected.destdir, *ro.destdir) + assert.Equal(t, expected.fs, ro.fs) + assert.Equal(t, expected.tmplDir, ro.tmplDir) + assert.Len(t, ro.parsers, len(expected.parsers)) }) } diff --git a/pkg/generate/run_test.go b/pkg/generate/run_test.go index 3d98657a..116d2402 100644 --- a/pkg/generate/run_test.go +++ b/pkg/generate/run_test.go @@ -1,233 +1,8 @@ package generate_test import ( - "context" - "errors" - "os" - "path" - "path/filepath" "testing" - - "github.com/kilianpaquier/cli-sdk/pkg/cfs" - testfs "github.com/kilianpaquier/cli-sdk/pkg/cfs/tests" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/kilianpaquier/craft/pkg/craft" - "github.com/kilianpaquier/craft/pkg/generate" ) func TestRun(t *testing.T) { - ctx := context.Background() - assertdir := filepath.Join("..", "..", "testdata", "run") - - t.Run("error_detection", func(t *testing.T) { - // Arrange - input := craft.Configuration{} - - // Act - _, err := generate.Run(ctx, input, - generate.WithDestination(t.TempDir()), - generate.WithDetects( // use a specific detect func to trigger the error - detectErr(errors.New("some error")), - detectErr(errors.New("another error")), - )) - - // Assert - assert.ErrorContains(t, err, "some error") - assert.ErrorContains(t, err, "another error") - }) - - t.Run("error_multiple_languages", func(t *testing.T) { - // Arrange - input := craft.Configuration{} - - // Act - _, err := generate.Run(ctx, input, - generate.WithDestination(t.TempDir()), - generate.WithDetects(detectMulti)) - - // Assert - assert.ErrorIs(t, err, generate.ErrMultipleLanguages) - }) - - t.Run("error_invalid_templates", func(t *testing.T) { - // Arrange - templates := path.Join("..", "..", "testdata", "run", "templates", "invalid") - input := craft.Configuration{} - - // Act - _, err := generate.Run(ctx, input, - generate.WithDelimiters("{{", "}}"), - generate.WithDestination(t.TempDir()), - generate.WithDetects(detectNoop, generate.DetectGeneric), // avoid testing detections since we only want the generic generation - generate.WithTemplates(templates, cfs.OS())) - - // Assert - assert.ErrorContains(t, err, "parse template file") - }) - - t.Run("success_valid_templates", func(t *testing.T) { - // Arrange - templates := path.Join("..", "..", "testdata", "run", "templates", "valid") - input := craft.Configuration{} - destdir := t.TempDir() - - readme := filepath.Join(destdir, "README.md") - t.Cleanup(func() { assert.NoError(t, os.Remove(readme)) }) - - // Act - _, err := generate.Run(ctx, input, - generate.WithDelimiters("{{", "}}"), - generate.WithDestination(destdir), - generate.WithDetects(detectNoop, generate.DetectGeneric), // avoid testing detections since we only want the generic generation - generate.WithTemplates(templates, cfs.OS())) - - // Assert - require.NoError(t, err) - bytes, err := os.ReadFile(readme) - require.NoError(t, err) - assert.Equal(t, []byte("# ."), bytes) - assert.NoFileExists(t, filepath.Join(destdir, "NOT_GENERATED.md")) - }) - - t.Run("success_generic", func(t *testing.T) { - // Arrange - assertdir := filepath.Join(assertdir, "generic") - destdir := filepath.Join(t.TempDir(), "generic") - require.NoError(t, os.Mkdir(destdir, cfs.RwxRxRxRx)) - - input := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - NoChart: true, - Platform: craft.GitHub, - } - - // Act - output, err := generate.Run(ctx, input, - generate.WithDestination(destdir), - generate.WithForceAll(true), - generate.WithTemplates("templates", cfs.OS())) - - // Assert - require.NoError(t, err) - assert.NoError(t, testfs.EqualDirs(assertdir, destdir)) - assert.Equal(t, input, output) - }) - - t.Run("success_golang", func(t *testing.T) { - // Arrange - assertdir := filepath.Join(assertdir, "golang") - destdir := filepath.Join(t.TempDir(), "golang") - require.NoError(t, os.Mkdir(destdir, cfs.RwxRxRxRx)) - - err := cfs.CopyFile(filepath.Join(assertdir, craft.Gomod), filepath.Join(destdir, craft.Gomod)) - require.NoError(t, err) - - input := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - } - expected := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - Platform: craft.GitHub, - } - - // Act - output, err := generate.Run(ctx, input, - generate.WithDestination(destdir), - generate.WithForceAll(true), - generate.WithTemplates("templates", generate.FS())) - - // Assert - require.NoError(t, err) - assert.NoError(t, testfs.EqualDirs(assertdir, destdir)) - assert.Equal(t, expected, output) - }) - - t.Run("success_hugo", func(t *testing.T) { - // Arrange - assertdir := filepath.Join(assertdir, "hugo") - destdir := filepath.Join(t.TempDir(), "hugo") - require.NoError(t, os.Mkdir(destdir, cfs.RwxRxRxRx)) - - err := cfs.CopyFile(filepath.Join(assertdir, craft.Gomod), filepath.Join(destdir, craft.Gomod)) - require.NoError(t, err) - err = cfs.CopyFile(filepath.Join(assertdir, "hugo.toml"), filepath.Join(destdir, "hugo.toml")) - require.NoError(t, err) - - input := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - NoMakefile: true, - } - expected := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - NoMakefile: true, - Platform: craft.GitHub, - } - - // Act - output, err := generate.Run(ctx, input, - generate.WithDestination(destdir), - generate.WithDetects(generate.DetectGolang), - generate.WithForceAll(true)) - - // Assert - require.NoError(t, err) - assert.NoError(t, testfs.EqualDirs(assertdir, destdir)) - assert.Equal(t, expected, output) - }) - - t.Run("success_nodejs", func(t *testing.T) { - // Arrange - assertdir := filepath.Join(assertdir, "nodejs") - destdir := filepath.Join(t.TempDir(), "nodejs") - require.NoError(t, os.Mkdir(destdir, cfs.RwxRxRxRx)) - - err := cfs.CopyFile(filepath.Join(assertdir, craft.PackageJSON), filepath.Join(destdir, craft.PackageJSON)) - require.NoError(t, err) - - input := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - NoChart: true, - Platform: craft.GitHub, - } - expected := craft.Configuration{ - Maintainers: []*craft.Maintainer{{Name: "maintainer name"}}, - NoChart: true, - NoMakefile: true, - Platform: craft.GitHub, - } - - // Act - output, err := generate.Run(ctx, input, - generate.WithDestination(destdir), - generate.WithForceAll(true)) - - // Assert - require.NoError(t, err) - assert.NoError(t, testfs.EqualDirs(assertdir, destdir)) - assert.Equal(t, expected, output) - }) -} - -func detectNoop(_ context.Context, _ string, _ *generate.Metadata) ([]generate.ExecFunc, error) { - return nil, nil -} - -var _ generate.DetectFunc = detectNoop // ensure interface is implemented - -func detectErr(err error) generate.DetectFunc { - return func(_ context.Context, _ string, _ *generate.Metadata) ([]generate.ExecFunc, error) { - return nil, err - } } - -var _ generate.DetectFunc = detectErr(nil) // ensure interface is implemented - -func detectMulti(_ context.Context, _ string, metadata *generate.Metadata) ([]generate.ExecFunc, error) { - metadata.Languages["lang1"] = "" - metadata.Languages["lang2"] = "" - return nil, nil -} - -var _ generate.DetectFunc = detectMulti // ensure interface is implemented diff --git a/pkg/generate/templates/.codecov.yml.tmpl b/pkg/generate/templates/.codecov.yml.tmpl deleted file mode 100644 index 1f0c0ca4..00000000 --- a/pkg/generate/templates/.codecov.yml.tmpl +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -coverage: - precision: 2 - round: down - range: 85...100 - - status: - project: - default: - threshold: 2.5% - patch: - default: - threshold: 2.5% - -<<- /* coverable is meant to be true only when there's at least on language that can be affected by coverage */ ->> -<<- $coverable := or (hasKey .Languages "golang") (hasKey .Languages "nodejs") >> - -<<- if $coverable >> - -ignore: -<<- if hasKey .Languages "golang" >> - - "cmd" - - "examples" - - "**/cobra/**" - - "**/mocks/**" - - "**/tests/**" - - "**/testutils/**" -<<- end >> -<<- if hasKey .Languages "nodejs" >> - - "dist" - - "node_modules" - - "**/*.spec.js" - - "**/*.spec.ts" - - "**/*.test.js" - - "**/*.test.ts" -<<- end >> -<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/.github/actions/version/action.yml.tmpl b/pkg/generate/templates/.github/actions/version/action.yml.tmpl deleted file mode 100644 index 0e27be61..00000000 --- a/pkg/generate/templates/.github/actions/version/action.yml.tmpl +++ /dev/null @@ -1,170 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -<<- $nodejs := hasKey .Languages "nodejs" >> -<<- $hugo := hasKey .Languages "hugo" >> -<<- $golang := hasKey .Languages "golang" >> - -<<- $gocli := and $golang (gt (len .Clis) 0) (not .NoGoreleaser) >> -<<- $nodepublish := and $nodejs (not (get .Languages "nodejs").Private) >> - -<<- if .CI.Release >> - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true -<<- if $nodepublish >> - npm_token: - description: Access token for the npm registry - required: true -<<- end >> -<<- end >> - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> - -<<- if not .CI.Release >> - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - git fetch --tags - - LAST_TAG=$(git tag --list | sort -V | tail -n1) - - NEXT_TAG=${LAST_TAG-1.0.0} - NEXT_TAG=${NEXT_TAG%-*} - - echo "version=v${NEXT_TAG#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} -<<- end >> - -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> - -<<- if .CI.Release >> -<<- /* retrieve dist for go binaries and nodejs dist folder (uploaded with semantic-release to npm registry) */ ->> -<<- if or $gocli $nodejs >> - - if: ${{ inputs.download_dist == 'true' }} - uses: actions/download-artifact@v4 - with: - name: build - path: dist -<<- end >> - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github -<<- if $nodejs >> - @semantic-release/npm -<<- end >> - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits -<<- if .License >> - semantic-release-license -<<- end >> -<<- if .CI.Release.Backmerge >> - @kilianpaquier/semantic-release-backmerge -<<- end >> - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} -<<- if $nodepublish >> - NPM_TOKEN: ${{ inputs.npm_token }} -<<- end >> - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} -<<- end >> - -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> -<<- /* *********************************************************************************************** */ ->> \ No newline at end of file diff --git a/pkg/generate/templates/.github/workflows/docker.yml.tmpl b/pkg/generate/templates/.github/workflows/docker.yml.tmpl deleted file mode 100644 index d07166f1..00000000 --- a/pkg/generate/templates/.github/workflows/docker.yml.tmpl +++ /dev/null @@ -1,191 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Docker -run-name: Docker - -<<- $nodejs := hasKey .Languages "nodejs" >> -<<- $hugo := hasKey .Languages "hugo" >> -<<- $golang := hasKey .Languages "golang" >> - -<<- $nodepublish := and $nodejs (not (get .Languages "nodejs").Private) >> - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - workflow_call: - inputs: - release: - description: Whether the docker built image must be propagated to major and minor tags or not - required: false - type: boolean - version: - description: The docker tag to build - required: false - type: string - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - version: - name: Version - runs-on: ubuntu-latest - environment: release - needs: run-workflow - if: ${{ github.event_name != 'pull_request' }} - permissions: - contents: write - issues: write - pull-requests: write -<<- if $nodejs >> - id-token: write -<<- end >> - outputs: - release: ${{ steps.version_merge.outputs.release }} - version: ${{ steps.version_merge.outputs.version }} - steps: - - uses: actions/checkout@v4 - - id: version - if: ${{ github.event_name == 'workflow_dispatch' }} - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} -<<- if and .HasRelease $nodepublish >> - npm_token: ${{ secrets.NPM_TOKEN }} -<<- end >> - - id: version_merge - run: | - if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then - echo "release=${RELEASE}" >> $GITHUB_OUTPUT - echo "version=${VERSION}" >> $GITHUB_OUTPUT - exit 0 - fi - echo "release=${INPUTS_RELEASE}" >> $GITHUB_OUTPUT - echo "version=${INPUTS_VERSION}" >> $GITHUB_OUTPUT - env: - VERSION: ${{ steps.version.outputs.version }} - RELEASE: ${{ steps.version.outputs.release }} - INPUTS_VERSION: ${{ inputs.version }} - INPUTS_RELEASE: ${{ inputs.release }} - - docker-hadolint: - name: Docker Hadolint - runs-on: ubuntu-latest - needs: run-workflow - permissions: - pull-requests: write - security-events: write - steps: - - uses: actions/checkout@v4 - - uses: hadolint/hadolint-action@v3.1.0 - with: - format: sarif - output-file: hadolint-results.sarif - - if: ${{ ! cancelled() }} - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: hadolint-results.sarif - category: docker-hadolint - - id: hadolint - if: ${{ ! cancelled() }} - uses: hadolint/hadolint-action@v3.1.0 - with: - format: tty - - docker-build: - name: Docker Build - runs-on: ubuntu-latest - environment: docker - needs: - - run-workflow - - version - outputs: - image: ${{ steps.image.outputs.image }} - steps: - - uses: actions/checkout@v4 - - id: image - run: | - IMAGE="<< with .Docker.Registry >><< . >>/<< end >>$GITHUB_REPOSITORY" - if [ "$RELEASE" != "true" ]; then - IMAGE="$IMAGE/snapshot" - fi - echo "image=$IMAGE" >> $GITHUB_OUTPUT - env: - RELEASE: ${{ needs.version.outputs.release }} - - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ steps.image.outputs.image }} - labels: | - org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} - org.opencontainers.image.ref.name="${{ github.ref_name }}" - org.opencontainers.image.version="${{ needs.version.outputs.version }}" - org.opencontainers.image.revision="${{ github.sha }}" - tags: | - type=raw,enable={{is_default_branch}},value=latest - type=semver,enable=true,pattern={{raw}},value=${{ needs.version.outputs.version }} - type=semver,enable=${{ needs.version.outputs.release }},pattern=v{{major}}.{{minor}},value=${{ needs.version.outputs.version }} - type=semver,enable=${{ needs.version.outputs.release }},pattern=v{{major}},value=${{ needs.version.outputs.version }} - - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v3 - with: -<<- if .Docker.Registry >> - registry: << .Docker.Registry >> -<<- end >> - username: ${{ github.repository_owner }} - password: ${{ secrets.REGISTRY_TOKEN }} - - uses: docker/build-push-action@v6 - with: - context: . - labels: ${{ steps.meta.outputs.labels }} - push: true - tags: ${{ steps.meta.outputs.tags }} - - docker-trivy: - name: Docker Trivy - runs-on: ubuntu-latest - environment: docker - permissions: - security-events: write - needs: - - run-workflow - - version - - docker-build - steps: - - uses: aquasecurity/trivy-action@master - with: - format: sarif - ignore-unfixed: false - image-ref: "${{ needs.docker-build.outputs.image }}:${{ needs.version.outputs.version }}" - output: trivy-results.sarif - severity: MEDIUM,HIGH,CRITICAL - env: - TRIVY_USERNAME: ${{ github.repository_owner }} - TRIVY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} - - uses: github/codeql-action/upload-sarif@v3 - with: - category: docker-trivy - sarif_file: trivy-results.sarif - - uses: aquasecurity/trivy-action@master - with: - exit-code: "1" - ignore-unfixed: false - image-ref: "${{ needs.docker-build.outputs.image }}:${{ needs.version.outputs.version }}" - severity: MEDIUM,HIGH,CRITICAL - env: - TRIVY_USERNAME: ${{ github.repository_owner }} - TRIVY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} \ No newline at end of file diff --git a/pkg/generate/templates/.github/workflows/netlify.yml.tmpl b/pkg/generate/templates/.github/workflows/netlify.yml.tmpl deleted file mode 100644 index 277a6b5a..00000000 --- a/pkg/generate/templates/.github/workflows/netlify.yml.tmpl +++ /dev/null @@ -1,89 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Netlify -run-name: Netlify - -<<- $nodejs := hasKey .Languages "nodejs" >> -<<- $hugo := hasKey .Languages "hugo" >> - -on: - workflow_call: - workflow_dispatch: -<<- if .CI.Static.Auto >> - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging -<<- /* avoid deploying two times when static and release are in auto mode */ ->> -<<- if not .IsAutoRelease >> - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x -<<- end >> -<<- end >> - -jobs: - -<<- if $hugo >> - - hugo: - name: Hugo - uses: ./.github/workflows/hugo.yml -<<- end >> - -<<- if $nodejs >> - - node: - name: Node - uses: ./.github/workflows/nodejs.yml - with: - build: true -<<- end >> - - netlify: - name: Netlify - runs-on: ubuntu-latest - environment: - name: netlify - url: ${{ steps.netlify.outputs.deploy-url }} - permissions: - deployments: write - pull-requests: write - needs: -<<- if $hugo >> - - hugo -<<- end >> -<<- if $nodejs >> - - node -<<- end >> - steps: - - uses: actions/checkout@v4 - - id: branch_sha - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - uses: actions/download-artifact@v4 - with: - name: build - path: dist - - id: netlify - uses: nwtgck/actions-netlify@v3 - with: - alias: ${{ steps.branch_sha.outputs.branch_sha }} - deploy-message: ${{ github.ref_name }} - enable-commit-comment: false - enable-commit-status: false - github-deployment-environment: netlify - github-token: ${{ secrets.GITHUB_TOKEN }} - netlify-config-path: netlify.toml - production-branch: ${{ github.event.repository.default_branch }} - publish-dir: dist - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} \ No newline at end of file diff --git a/pkg/generate/templates/.github/workflows/pages.yml.tmpl b/pkg/generate/templates/.github/workflows/pages.yml.tmpl deleted file mode 100644 index ab576d7a..00000000 --- a/pkg/generate/templates/.github/workflows/pages.yml.tmpl +++ /dev/null @@ -1,61 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Pages -run-name: Pages - -<<- $nodejs := hasKey .Languages "nodejs" >> -<<- $hugo := hasKey .Languages "hugo" >> - -on: - workflow_call: - workflow_dispatch: -<<- /* avoid deploying two times when static and release are in auto mode */ ->> -<<- if and .CI.Static.Auto (not .IsAutoRelease) >> - push: - branches: - - main - - master - - v[0-9]+.x - - v[0-9]+.[0-9]+.x -<<- end >> - -jobs: - -<<- if $hugo >> - - hugo: - name: Hugo - uses: ./.github/workflows/hugo.yml -<<- end >> - -<<- if $nodejs >> - - node: - name: Node - uses: ./.github/workflows/nodejs.yml - with: - build: true -<<- end >> - - pages: - name: Pages - runs-on: ubuntu-latest - needs: -<<- if $hugo >> - - hugo -<<- end >> -<<- if $nodejs >> - - node -<<- end >> - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - permissions: - pages: write - id-token: write - steps: - - id: deployment - uses: actions/deploy-pages@v4 - with: - artifact_name: github-pages - preview: ${{ github.ref_name != github.event.repository.default_branch }} \ No newline at end of file diff --git a/pkg/generate/templates/.github/workflows/release.yml.tmpl b/pkg/generate/templates/.github/workflows/release.yml.tmpl deleted file mode 100644 index b36dc96a..00000000 --- a/pkg/generate/templates/.github/workflows/release.yml.tmpl +++ /dev/null @@ -1,241 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -<<- $nodejs := hasKey .Languages "nodejs" >> -<<- $hugo := hasKey .Languages "hugo" >> -<<- $golang := hasKey .Languages "golang" >> - -<<- $gocli := and $golang (gt (len .Clis) 0) (not .NoGoreleaser) >> -<<- $nodebuild := and $nodejs ((get .Languages "nodejs").Main) >> -<<- $nodepublish := and $nodejs (not (get .Languages "nodejs").Private) >> -<<- $docker := and .Docker (gt .Binaries 0) >> - -<<- $pages := and (.IsStatic "pages") (or $nodejs $hugo) >> -<<- $netlify := and (.IsStatic "netlify") (or $nodejs $hugo) >> - -<<- $auth := fromPtr .CI.Auth.Release >> - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release -<<- if .IsAutoRelease >> - push: - branches: - - main - - master - - v[0-9]+.x - - v[0-9]+.[0-9]+.x -<<- end >> - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release -<<- if or (eq $auth "github-token") $nodejs >> - permissions: -<<- if eq $auth "github-token" >> - contents: write - issues: write - pull-requests: write -<<- end >> -<<- if $nodejs >> - id-token: write -<<- end >> -<<- end >> - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: -<<- if eq $auth "github-app" >> - - id: app_token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.RELEASE_APP_ID }} - private-key: ${{ secrets.PRIVATE_KEY }} -<<- end >> - - uses: actions/checkout@v4 -<<- if or (.CI.Release.Backmerge) (ne $auth "github-token") >> - with: -<<- if .CI.Release.Backmerge >> - fetch-depth: 0 -<<- end >> -<<- if eq $auth "github-app" >> - token: ${{ steps.app_token.outputs.token }} -<<- end >> -<<- if ne $auth "github-token" >> - persist-credentials: false -<<- end >> -<<- end >> - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build -<<- if eq $auth "github-app" >> - token: ${{ steps.app_token.outputs.token }} -<<- else if eq $auth "personal-token" >> - token: ${{ secrets.RELEASE_TOKEN }} -<<- else >> - token: ${{ secrets.GITHUB_TOKEN }} -<<- end >> -<<- if $nodepublish >> - npm_token: ${{ secrets.NPM_TOKEN }} -<<- end >> - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - -<<- if $golang >> - - golang: - name: Golang - needs: version - uses: ./.github/workflows/golang.yml - permissions: - checks: write - with: -<<- if $gocli >> - build: true -<<- end >> - version: ${{ needs.version.outputs.version }} - secrets: inherit -<<- end >> - -<<- if $nodejs >> - - node: - name: Node - uses: ./.github/workflows/nodejs.yml -<<- if $nodebuild >> - with: - build: true -<<- end >> - secrets: inherit -<<- end >> - -<<- if $docker >> - - docker: - name: Docker - needs: version - uses: ./.github/workflows/docker.yml - permissions: - contents: write - issues: write - pull-requests: write -<<- if $nodejs >> - id-token: write -<<- end >> - security-events: write - with: - version: ${{ needs.version.outputs.version }} - release: ${{ needs.version.outputs.release == 'true' }} - secrets: inherit -<<- end >> - -<<- if $netlify >> - - netlify: - name: Netlify - uses: ./.github/workflows/netlify.yml - permissions: - deployments: write - pull-requests: write - secrets: inherit -<<- end >> - -<<- if $pages >> - - pages: - name: Pages - uses: ./.github/workflows/pages.yml - permissions: - pages: write - id-token: write -<<- end >> - - release: - name: Release - runs-on: ubuntu-latest - environment: release -<<- if or (eq $auth "github-token") $nodejs >> - permissions: -<<- if eq $auth "github-token" >> - contents: write - issues: write - pull-requests: write -<<- end >> -<<- if $nodejs >> - id-token: write -<<- end >> -<<- end >> - needs: - - version -<<- if $golang >> - - golang -<<- end >> -<<- if $nodejs >> - - node -<<- end >> -<<- if $docker >> - - docker -<<- end >> -<<- if $netlify >> - - netlify -<<- end >> -<<- if $pages >> - - pages -<<- end >> - steps: -<<- if eq $auth "github-app" >> - - id: app_token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.RELEASE_APP_ID }} - private-key: ${{ secrets.PRIVATE_KEY }} -<<- end >> - - uses: actions/checkout@v4 -<<- if or (.CI.Release.Backmerge) (ne $auth "github-token") >> - with: -<<- if .CI.Release.Backmerge >> - fetch-depth: 0 -<<- end >> -<<- if eq $auth "github-app" >> - token: ${{ steps.app_token.outputs.token }} -<<- end >> -<<- if ne $auth "github-token" >> - persist-credentials: false -<<- end >> -<<- end >> - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} -<<- if eq $auth "github-app" >> - token: ${{ steps.app_token.outputs.token }} -<<- else if eq $auth "personal-token" >> - token: ${{ secrets.RELEASE_TOKEN }} -<<- else >> - token: ${{ secrets.GITHUB_TOKEN }} -<<- end >> -<<- if $nodepublish >> - npm_token: ${{ secrets.NPM_TOKEN }} -<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/.gitlab/semrel-plugins.txt.tmpl b/pkg/generate/templates/.gitlab/semrel-plugins.txt.tmpl deleted file mode 100644 index 51114600..00000000 --- a/pkg/generate/templates/.gitlab/semrel-plugins.txt.tmpl +++ /dev/null @@ -1,16 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -<<- if hasKey .Languages "nodejs" >> -@semantic-release/npm -<<- end >> -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits -<<- if .License >> -semantic-release-license -<<- end >> -<<- if and .CI.Release .CI.Release.Backmerge >> -@kilianpaquier/semantic-release-backmerge -<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/README.md.tmpl b/pkg/generate/templates/README.md.tmpl deleted file mode 100644 index aade6ccd..00000000 --- a/pkg/generate/templates/README.md.tmpl +++ /dev/null @@ -1,47 +0,0 @@ - - -# << .ProjectName >> - -<<- /* coverable is meant to be true only when there's at least on language that can be affected by coverage */ ->> -<<- $coverable := or (hasKey .Languages "golang") (hasKey .Languages "nodejs") >> - -

-<<- $style := "for-the-badge" >> -<<- $branch := "main" >> - -<<- if eq .Platform "github" >> - GitHub Release - GitHub Issues -<<- if .License >> - GitHub License -<<- end >> -<<- end >> - -<<- if eq .Platform "gitlab" >> -<<- $url := toQuery (print "https://" .ProjectHost) >> - GitLab Release - GitLab Issues -<<- if .License >> - GitLab License -<<- end >> -<<- end >> - -<<- if and $coverable .CI >> -<<- if has "codecov" .CI.Options >> - Coverage -<<- end >> -<<- if has "sonar" .CI.Options >> -<<- $url := toQuery "https://sonarcloud.io" >> - Coverage>/<< $branch >>?server=<< $url >>&style=<< $style >>"> -<<- end >> -<<- end >> - -<<- if or (hasKey .Languages "golang") (hasKey .Languages "hugo") >> - Go Version>"> -<<- end >> -<<- if or (hasKey .Languages "golang") >> - Go Report Card>?style=<< $style >>"> -<<- end >> -

- ---- \ No newline at end of file diff --git a/pkg/generate/templates/lang_golang/Dockerfile.tmpl b/pkg/generate/templates/lang_golang/Dockerfile.tmpl deleted file mode 100644 index 8891de57..00000000 --- a/pkg/generate/templates/lang_golang/Dockerfile.tmpl +++ /dev/null @@ -1,72 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -<<- $specifics := get .Languages "golang" >> - -<<- $binaries := dict >> -<<- $_ := map $binaries .Clis .Crons .Jobs .Workers >> - -<<- $maintainer := index .Maintainers 0 >> - -############################# -# STAGE BUILD # -############################# -FROM golang:<< $specifics.LangVersion >> AS build - -WORKDIR /app - -COPY . . - -# hadolint ignore=DL3059 -RUN go mod download - -<<- range $name, $config := $binaries >> -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o << $name >> cmd/<< $name >>/main.go -<<- end >> - -############################# -# STAGE RUN # -############################# -FROM gcr.io/distroless/static-debian12:nonroot - -LABEL org.opencontainers.image.authors="<< $maintainer.Name >><< if $maintainer.Email >> <<"<">><< $maintainer.Email >><<">">><< end >>" -LABEL org.opencontainers.image.vendor="<< $maintainer.Name >>" - -LABEL org.opencontainers.image.title="<< .ProjectName >>" -<<- if .Description >> -LABEL org.opencontainers.image.description="<< .Description >>" -<<- end >> -<<- if .License >> -LABEL org.opencontainers.image.licenses="<< upper .License >>" -<<- end >> -LABEL org.opencontainers.image.url="<< print .ProjectHost "/" .ProjectPath >>" -LABEL org.opencontainers.image.source="<< print .ProjectHost "/" .ProjectPath >>" -LABEL org.opencontainers.image.documentation="<< print .ProjectHost "/" .ProjectPath >>" - -WORKDIR /app - -COPY --from=build \ -<<- range $name, $config := $binaries >> - /app/<< $name >> \ -<<- end >> - ./ - -<<- $entrypoint := "launcher.sh" >> - -<<- if eq .Binaries 1 >> - -<<- /* directly use the only binary */ ->> -<<- range $name, $config := $binaries >> -<<- $entrypoint = $name >> -<<- end >> - -<<- end >> - -<<- /* copy launcher if the entrypoint is the launcher */ ->> -<<- if eq $entrypoint "launcher.sh" >> -COPY launcher.sh launcher.sh -<<- end >> - -EXPOSE << .Docker.Port | default 3000 >> - -ENTRYPOINT [ "/app/<< $entrypoint >>" ] \ No newline at end of file diff --git a/pkg/generate/templates/lang_golang/launcher.sh.tmpl b/pkg/generate/templates/lang_golang/launcher.sh.tmpl deleted file mode 100644 index d149439a..00000000 --- a/pkg/generate/templates/lang_golang/launcher.sh.tmpl +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Code generated by craft; DO NOT EDIT. - -case $BINARY_NAME in - -<<- $binaries := dict >> -<<- $_ := map $binaries .Clis .Crons .Jobs .Workers >> - -<<- range $name, $config := $binaries >> - << $name >>) /app/<< $name >>;; -<<- end >> - *) echo "invalid binary '$BINARY_NAME'" && exit 1;; -esac \ No newline at end of file diff --git a/pkg/generate/templates/lang_golang/scripts/build.mk.tmpl b/pkg/generate/templates/lang_golang/scripts/build.mk.tmpl deleted file mode 100644 index 33884eee..00000000 --- a/pkg/generate/templates/lang_golang/scripts/build.mk.tmpl +++ /dev/null @@ -1,53 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - -<<- $binaries := dict >> -<<- $_ := map $binaries .Clis .Crons .Jobs .Workers >> - -<<- if (gt .Binaries 0) >> - -.PHONY: buildall -buildall:<< range $name, $config := $binaries >> build-<< $name >><< end >> - -.PHONY:<< range $name, $config := $binaries >> << $name >><< end >> -build-%: - @CGO_ENABLED=0 go build -o $* cmd/$*/main.go - -.PHONY:<< range $name, $config := $binaries >> << $name >><< end >> -local-%: - @go run cmd/$*/main.go - -<<- if .Docker >> - -.PHONY: build-docker -build-docker: - @docker build -t << .ProjectName >> . -<<- end >> -<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/lang_golang/scripts/install.mk.tmpl b/pkg/generate/templates/lang_golang/scripts/install.mk.tmpl deleted file mode 100644 index 2a56631f..00000000 --- a/pkg/generate/templates/lang_golang/scripts/install.mk.tmpl +++ /dev/null @@ -1,44 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: - -<<- $binaries := dict >> -<<- $_ := map $binaries .Clis .Crons .Jobs .Workers >> - -<<- if and .Docker (gt .Binaries 0) >> - -define install_docker -if which docker >/dev/null; then - echo "docker already installed" - exit 0 -fi - -echo "installing docker" -curl -fsSL https://get.docker.com | bash -dockerd-rootless-setuptool.sh install -endef -.PHONY: install-docker -install-docker: ; @$(value install_docker) -.ONESHELL: -<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/lang_golang/sonar.properties.tmpl b/pkg/generate/templates/lang_golang/sonar.properties.tmpl deleted file mode 100644 index 44177a7a..00000000 --- a/pkg/generate/templates/lang_golang/sonar.properties.tmpl +++ /dev/null @@ -1,22 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -sonar.host.url=https://sonarcloud.io -sonar.qualitygate.wait=true - -<<- $maintainer := index .Maintainers 0 >> - -sonar.organization=<< $maintainer.Name >> -sonar.projectBaseDir=. -sonar.projectKey=<< .ProjectPath | replace "/" "_" >> -sonar.projectName=<< .ProjectName >> - -sonar.exclusions=**/examples/**,**/testdata/**,**/vendor/** -sonar.coverage.exclusions=cmd/**,**/cobra/**,**/tests/**,**/testutils/** -sonar.test.inclusions=**/*_test.go - -<<- if eq .CI.Name "gitlab" >> - -sonar.go.tests.reportPaths=reports/go-test.native.json -<<- end >> -sonar.go.coverage.reportPaths=reports/go-coverage.native.out -sonar.go.golangci-lint.reportPaths=reports/go-ci-lint.checkstyle.xml \ No newline at end of file diff --git a/pkg/generate/templates/lang_helm/values.yaml.tmpl b/pkg/generate/templates/lang_helm/values.yaml.tmpl deleted file mode 100644 index 1a65ef78..00000000 --- a/pkg/generate/templates/lang_helm/values.yaml.tmpl +++ /dev/null @@ -1,578 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -<<- $kubeVersion := "v1.30" >> -<<- $maintainer := index .maintainers 0 >> - -<< with .imagePullSecrets >> -imagePullSecrets: - <<- toYaml . | nindent 2 >> -<< else ->> -imagePullSecrets: [] -<<- end >> - -nameOverride: << .nameOverride | default ("" | quote) >> -fullnameOverride: << .fullnameOverride | default ("" | quote) >> - -serviceAccount: - # Specifies whether a service account should be created - create: << .serviceAccount.create | default "false" >> - # Annotations to add to the service account - <<- with .serviceAccount.annotations >> - annotations: - <<- toYaml . | nindent 4 >> - <<- else >> - annotations: {} - <<- end >> - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: << .serviceAccount.name | default ("" | quote) >> - -############################################# -# all cronjobs # -############################################# -<<- with .crons >> -crons: -<<- range $name, $config := . >> - << $name >>: - suspend: true - schedule: << $config.schedule | default "*/1 * * * *" | quote >> - concurrencyPolicy: << $config.concurrencyPolicy | default "Forbid" >> - completionMode: << $config.completionMode | default "NonIndexed" >> - completions: << $config.completions | default 1 >> - parallelism: << $config.parallelism | default 1 >> - image: - registry: << $config.image.registry | default $.docker.registry | default ("" | quote) >> - repository: << $config.image.repository | default $.projectPath >> - pullPolicy: << $config.image.pullPolicy | default ("" | quote) >> - # Overrides the image tag whose default is the chart appVersion. - tag: << $config.image.tag | default "" | quote >> - env: - <<- $env := merge (dict "BINARY_NAME" $name) (dict "BINARY_PORT" ($.docker.port | default 3000)) $config.env >> - <<- toYaml $env | nindent 6 >> - <<- with $config.envFrom >> - envFrom: - <<- toYaml . | nindent 6 >> - <<- else >> - envFrom: [] - # - prefix: "" - # configMapRef: - # name: "" - # secretRef: - # name: "" - <<- end >> - resources: - limits: - cpu: << $config.resources.limits.cpu | default "250m" >> - memory: << $config.resources.limits.memory | default "256Mi" >> - storage: << $config.resources.limits.storage | default "10Gi" >> - requests: - cpu: << $config.resources.requests.cpu | default "50m" >> - memory: << $config.resources.requests.memory | default "128Mi" >> - storage: << $config.resources.requests.storage | default "5Gi" >> - failedJobsHistoryLimit: << $config.failedJobsHistoryLimit | default 1 >> - successfulJobsHistoryLimit: << $config.successfulJobsHistoryLimit | default 3 >> - restartPolicy: << $config.restartPolicy | default "OnFailure" >> - <<- with $config.configMap >> - configMap: - <<- toYaml . | nindent 6 >> - <<- else >> - configMap: {} - # mountPath: /etc/config/ - # tpl_folders: # folders to be included in configmap with tpl - # - folder_name - # include_folders: # folders to be included in configmap without tpl - # - folder_name - # data: - # name: value - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#volume-v1-core - <<- with $config.volumes >> - volumes: - <<- toYaml . | nindent 6 >> - <<- else >> - volumes: [] - # - name: "" - # configMap: - # name: configMapName - # - name: "" - # emptyDir: - # medium: "" - # sizeLimit: 1Gi - # - name: "" - # persistentVolumeClaim: - # claimName: "" - # readOnly: false - # - name: "" - # secret: - # secretName: "" - <<- end >> - <<- with $config.volumeMounts >> - volumeMounts: - <<- toYaml . | nindent 6 >> - <<- else >> - volumeMounts: [] - # - mountPath: /etc/config/ - # name: volume[*].name - # readOnly: true - <<- end >> - - << with $config.podAnnotations ->> - podAnnotations: - <<- toYaml . | nindent 6 >> - << else ->> - podAnnotations: {} - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#podsecuritycontext-v1-core - <<- with $config.podSecurityContext >> - podSecurityContext: - <<- toYaml . | nindent 6 >> - <<- else >> - podSecurityContext: {} - <<- end >> - # fsGroup: 2 - # fsGroupChangePolicy: Always | OnRootMismatch - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#securitycontext-v1-core - <<- with $config.securityContext >> - securityContext: - <<- toYaml . | nindent 6 >> - <<- else >> - securityContext: {} - # allowPrivilegeEscalation: false - # capabilities: - # add: [] - # drop: [] - # privileged: false - # readOnlyRootFilesystem: true - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#nodeselector-v1-core - << with $config.nodeSelector ->> - nodeSelector: - <<- toYaml . | nindent 6 >> - << else ->> - nodeSelector: {} - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#toleration-v1-core - <<- with $config.tolerations >> - tolerations: - <<- toYaml . | nindent 6 >> - <<- else >> - tolerations: [] - # - effect: NoSchedule | PreferNoSchedule | NoExecute - # key: "" - # operator: Exists | Equal - # tolerationSeconds: 600 - # value: "" - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#affinity-v1-core - <<- with $config.affinity >> - affinity: - <<- toYaml . | nindent 6 >> - <<- else >> - affinity: {} - <<- end >> -<< end >> -<<- else >> -crons: {} -<<- end >> - -############################################# -# all jobs # -############################################# -<<- with .jobs >> -jobs: -<<- range $name, $config := . >> - << $name >>: - suspend: true - completionMode: << $config.completionMode | default "NonIndexed" >> - completions: << $config.completions | default 1 >> - parallelism: << $config.parallelism | default 1 >> - <<- with $config.ttlSecondsAfterFinished >> - ttlSecondsAfterFinished: << . >> - <<- end >> - image: - registry: << $config.image.registry | default $.docker.registry | default ("" | quote) >> - repository: << $config.image.repository | default $.projectPath >> - pullPolicy: << $config.image.pullPolicy | default ("" | quote) >> - # Overrides the image tag whose default is the chart appVersion. - tag: << $config.image.tag | default "" | quote >> - env: - <<- $env := merge (dict "BINARY_NAME" $name) (dict "BINARY_PORT" ($.docker.port | default 3000)) $config.env >> - <<- toYaml $env | nindent 6 >> - <<- with $config.envFrom >> - envFrom: - <<- toYaml . | nindent 6 >> - <<- else >> - envFrom: [] - # - prefix: "" - # configMapRef: - # name: "" - # secretRef: - # name: "" - <<- end >> - resources: - limits: - cpu: << $config.resources.limits.cpu | default "250m" >> - memory: << $config.resources.limits.memory | default "256Mi" >> - storage: << $config.resources.limits.storage | default "10Gi" >> - requests: - cpu: << $config.resources.requests.cpu | default "50m" >> - memory: << $config.resources.requests.memory | default "128Mi" >> - storage: << $config.resources.requests.storage | default "5Gi" >> - restartPolicy: << $config.RestartPolicy | default "OnFailure" >> - <<- with $config.configMap >> - configMap: - <<- toYaml . | nindent 6 >> - <<- else >> - configMap: {} - # mountPath: /etc/config/ - # tpl_folders: # folders to be included in configmap with tpl - # - folder_name - # include_folders: # folders to be included in configmap without tpl - # - folder_name - # data: - # name: value - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#volume-v1-core - <<- with $config.volumes >> - volumes: - <<- toYaml . | nindent 6 >> - <<- else >> - volumes: [] - # - name: "" - # configMap: - # name: configMapName - # - name: "" - # emptyDir: - # medium: "" - # sizeLimit: 1Gi - # - name: "" - # persistentVolumeClaim: - # claimName: "" - # readOnly: false - # - name: "" - # secret: - # secretName: "" - <<- end >> - <<- with $config.volumeMounts >> - volumeMounts: - <<- toYaml . | nindent 6 >> - <<- else >> - volumeMounts: [] - # - mountPath: /etc/config/ - # name: volume[*].name - # readOnly: true - <<- end >> - - << with $config.podAnnotations ->> - podAnnotations: - <<- toYaml . | nindent 6 >> - << else ->> - podAnnotations: {} - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#podsecuritycontext-v1-core - <<- with $config.podSecurityContext >> - podSecurityContext: - <<- toYaml . | nindent 6 >> - <<- else >> - podSecurityContext: {} - <<- end >> - # fsGroup: 2 - # fsGroupChangePolicy: Always | OnRootMismatch - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#securitycontext-v1-core - <<- with $config.securityContext >> - securityContext: - <<- toYaml . | nindent 6 >> - <<- else >> - securityContext: {} - # allowPrivilegeEscalation: false - # capabilities: - # add: [] - # drop: [] - # privileged: false - # readOnlyRootFilesystem: true - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#nodeselector-v1-core - << with $config.nodeSelector ->> - nodeSelector: - <<- toYaml . | nindent 6 >> - << else ->> - nodeSelector: {} - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#toleration-v1-core - <<- with $config.tolerations >> - tolerations: - <<- toYaml . | nindent 6 >> - <<- else >> - tolerations: [] - # - effect: NoSchedule | PreferNoSchedule | NoExecute - # key: "" - # operator: Exists | Equal - # tolerationSeconds: 600 - # value: "" - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#affinity-v1-core - <<- with $config.affinity >> - affinity: - <<- toYaml . | nindent 6 >> - <<- else >> - affinity: {} - <<- end >> -<< end >> -<<- else >> -jobs: {} -<<- end >> - -############################################# -# all workers # -############################################# -<<- with .workers >> -workers: -<<- range $name, $config := . >> - << $name >>: - paused: true - replicaCount: << $config.replicaCount | default 1 >> - image: - registry: << $config.image.registry | default $.docker.registry | default ("" | quote) >> - repository: << $config.image.repository | default $.projectPath >> - pullPolicy: << $config.image.pullPolicy | default ("" | quote) >> - # Overrides the image tag whose default is the chart appVersion. - tag: << $config.image.tag | default "" | quote >> - env: - <<- $env := merge (dict "BINARY_NAME" $name) (dict "BINARY_PORT" ($.docker.port | default 3000)) $config.env >> - <<- toYaml $env | nindent 6 >> - <<- with $config.envFrom >> - envFrom: - <<- toYaml . | nindent 6 >> - <<- else >> - envFrom: [] - # - prefix: "" - # configMapRef: - # name: "" - # secretRef: - # name: "" - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#probe-v1-core - << with $config.livenessProbe ->> - livenessProbe: - <<- toYaml . | nindent 6 >> - << else ->> - livenessProbe: false - # httpGet: - # httpHeaders: - # header-name: value - # path: /ping - # port: 3000 - # scheme: http - # initialDelaySeconds: 15 - # periodSeconds: 10 - # successThreshold: 1 - # failureThreshold: 3 - <<- end >> - <<- with $config.readinessProbe >> - readinessProbe: - <<- toYaml . | nindent 6 >> - <<- else >> - readinessProbe: false - # exec: - # command: ["ls", "-lart"] - # initialDelaySeconds: 15 - # periodSeconds: 10 - # successThreshold: 1 - # failureThreshold: 3 - <<- end >> - <<- with $config.startupProbe >> - startupProbe: - <<- toYaml . | nindent 6 >> - <<- else >> - startupProbe: false - # grpc: - # port: 3000 - # service: "" - # initialDelaySeconds: 15 - # periodSeconds: 10 - # successThreshold: 1 - # failureThreshold: 3 - <<- end >> - resources: - limits: - cpu: << $config.resources.limits.cpu | default "250m" >> - memory: << $config.resources.limits.memory | default "256Mi" >> - storage: << $config.resources.limits.storage | default "10Gi" >> - requests: - cpu: << $config.resources.requests.cpu | default "50m" >> - memory: << $config.resources.requests.memory | default "128Mi" >> - storage: << $config.resources.requests.storage | default "5Gi" >> - autoscaling: - enabled: << $config.autoscaling.enabled | default "false" >> - minReplicas: << $config.autoscaling.minReplicas | default 1 >> - maxReplicas: << $config.autoscaling.maxReplicas | default 10 >> - <<- with $config.autoscaling.metrics >> - metrics: - <<- toYaml . | nindent 8 >> - <<- else >> - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 80 - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: 80 - <<- end >> - restartPolicy: << $config.restartPolicy | default "Always" >> - <<- with $config.configMap >> - configMap: - <<- toYaml . | nindent 6 >> - <<- else >> - configMap: {} - # mountPath: /etc/config/ - # tpl_folders: # folders to be included in configmap with tpl - # - folder_name - # include_folders: # folders to be included in configmap without tpl - # - folder_name - # data: - # name: value - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#volume-v1-core - <<- with $config.volumes >> - volumes: - <<- toYaml . | nindent 6 >> - <<- else >> - volumes: [] - # - name: "" - # configMap: - # name: configMapName - # - name: "" - # emptyDir: - # medium: "" - # sizeLimit: 1Gi - # - name: "" - # persistentVolumeClaim: - # claimName: "" - # readOnly: false - # - name: "" - # secret: - # secretName: "" - <<- end >> - <<- with $config.volumeMounts >> - volumeMounts: - <<- toYaml . | nindent 6 >> - <<- else >> - volumeMounts: [] - # - mountPath: /etc/config/ - # name: volume[*].name - # readOnly: true - <<- end >> - - << with $config.podAnnotations ->> - podAnnotations: - <<- toYaml . | nindent 6 >> - << else ->> - podAnnotations: {} - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#podsecuritycontext-v1-core - <<- with $config.podSecurityContext >> - podSecurityContext: - <<- toYaml . | nindent 6 >> - <<- else >> - podSecurityContext: {} - <<- end >> - # fsGroup: 2 - # fsGroupChangePolicy: Always | OnRootMismatch - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#securitycontext-v1-core - <<- with $config.securityContext >> - securityContext: - <<- toYaml . | nindent 6 >> - <<- else >> - securityContext: {} - # allowPrivilegeEscalation: false - # capabilities: - # add: [] - # drop: [] - # privileged: false - # readOnlyRootFilesystem: true - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#nodeselector-v1-core - << with $config.nodeSelector ->> - nodeSelector: - <<- toYaml . | nindent 6 >> - << else ->> - nodeSelector: {} - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#toleration-v1-core - <<- with $config.tolerations >> - tolerations: - <<- toYaml . | nindent 6 >> - <<- else >> - tolerations: [] - # - effect: NoSchedule | PreferNoSchedule | NoExecute - # key: "" - # operator: Exists | Equal - # tolerationSeconds: 600 - # value: "" - <<- end >> - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/<< $kubeVersion >>/#affinity-v1-core - <<- with $config.affinity >> - affinity: - <<- toYaml . | nindent 6 >> - <<- else >> - affinity: {} - <<- end >> -<< end >> -<<- else >> -workers: {} -<<- end >> - -############################################# -# all dependencies # -############################################# -<<- range .dependencies >> -<<- if .values >> -<< .name >>: - <<- toYaml .values | nindent 2 >> -<<- else >> -<< .name >>: {} -<<- end >> -<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/lang_hugo/.gitignore.tmpl b/pkg/generate/templates/lang_hugo/.gitignore.tmpl deleted file mode 100644 index 2a7ae709..00000000 --- a/pkg/generate/templates/lang_hugo/.gitignore.tmpl +++ /dev/null @@ -1,22 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock - -<<- if .IsStatic "netlify" >> - -# Local Netlify folder -.netlify -<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/lang_nodejs/.gitignore.tmpl b/pkg/generate/templates/lang_nodejs/.gitignore.tmpl deleted file mode 100644 index e3d3da66..00000000 --- a/pkg/generate/templates/lang_nodejs/.gitignore.tmpl +++ /dev/null @@ -1,139 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -<<- if .IsStatic "netlify" >> - -# Local Netlify folder -.netlify -<<- end >> \ No newline at end of file diff --git a/pkg/generate/templates/lang_nodejs/sonar.properties.tmpl b/pkg/generate/templates/lang_nodejs/sonar.properties.tmpl deleted file mode 100644 index 9a05b1d8..00000000 --- a/pkg/generate/templates/lang_nodejs/sonar.properties.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -sonar.host.url=https://sonarcloud.io -sonar.qualitygate.wait=true - -<<- $maintainer := index .Maintainers 0 >> - -sonar.organization=<< $maintainer.Name >> -sonar.projectBaseDir=. -sonar.projectKey=<< .ProjectPath | replace "/" "_" >> -sonar.projectName=<< .ProjectName >> - -sonar.exclusions=node_modules/**,dist/**,**/*.spec.js,**/*.spec.ts,**/*.test.js,**/*.test.ts -sonar.test.inclusions=**/*.spec.js,**/*.spec.ts,**/*.test.js,**/*.test.ts - -sonar.testExecutionReportPaths=reports/node-test.sonar.xml -sonar.eslint.reportPaths=reports/node-lint.xslint.json -sonar.javascript.lcov.reportPaths=reports/lcov.info \ No newline at end of file diff --git a/pkg/generate/types/doc.go b/pkg/generate/types/doc.go new file mode 100644 index 00000000..eb834779 --- /dev/null +++ b/pkg/generate/types/doc.go @@ -0,0 +1 @@ +package generate diff --git a/pkg/generate/types/metadata.go b/pkg/generate/types/metadata.go new file mode 100644 index 00000000..146267f2 --- /dev/null +++ b/pkg/generate/types/metadata.go @@ -0,0 +1,48 @@ +package generate + +import "github.com/kilianpaquier/craft/pkg/craft" + +// Metadata represents all properties available for enrichment during repository parsing. +// +// Updated properties will be used during generation to determine if a specific file or part of a file must be generated. +type Metadata struct { + craft.Configuration + + // Languages is a map of languages name with its specificities. + Languages map[string]any `json:"-"` + + // ProjectHost represents the host where the project is hosted. + // + // As craft only handles git, it would be an host like github.com, gitlab.com, bitbucket.org, etc. + // + // Of course it can also be a private host like github.company.com. + // + // It will depend on the git origin URL or for golang the host of go.mod module name. + ProjectHost string `json:"projectHost,omitempty"` + + // ProjectName is the project name being generated. + // By default with Run function, it will be the base path of ParseRemote's subpath result following OriginURL result. + ProjectName string `json:"projectName,omitempty"` + + // ProjectPath is the project path. + // By default with Run function, it will be the subpath in ParseRemote result. + ProjectPath string `json:"projectPath,omitempty"` + + // Binaries is the total number of binaries / executables parsed during craft execution. + // + // It's especially used for golang generation (with workers, cronjob, jobs, etc.) + // but also in nodejs generation in case a "main" property is present in package.json. + Binaries uint8 `json:"-"` + + // Clis is a map of CLI names without value (empty struct). + Clis map[string]struct{} `json:"-"` + + // Crons is a map of cronjob names without value (empty struct). + Crons map[string]struct{} `json:"crons,omitempty"` + + // Jobs is a map of job names without value (empty struct). + Jobs map[string]struct{} `json:"jobs,omitempty"` + + // Workers is a map of workers names without value (empty struct). + Workers map[string]struct{} `json:"workers,omitempty"` +} diff --git a/pkg/generate/types_fs.go b/pkg/generate/types_fs.go new file mode 100644 index 00000000..acd570a8 --- /dev/null +++ b/pkg/generate/types_fs.go @@ -0,0 +1,17 @@ +package generate + +import ( + "embed" + + "github.com/kilianpaquier/cli-sdk/pkg/cfs" +) + +//go:embed all:_templates +var tmpl embed.FS + +var _ cfs.FS = (*embed.FS)(nil) // ensure interface is implemented + +// FS returns the default fs (embedded) used by craft when not extended as a SDK. +func FS() cfs.FS { + return tmpl +} diff --git a/scripts/custom.mk b/scripts/custom.mk index 59b2ba6e..ec3cb11a 100644 --- a/scripts/custom.mk +++ b/scripts/custom.mk @@ -1,11 +1,11 @@ .PHONY: examples examples: buildall - @(cd examples/generic_github && ../../craft generate --force-all) - @(cd examples/generic_gitlab && ../../craft generate --force-all) - @(cd examples/golang_github && go mod tidy && ../../craft generate --force-all) - @(cd examples/golang_gitlab && go mod tidy && ../../craft generate --force-all) - @(cd examples/hugo_github && go mod tidy && ../../craft generate --force-all) - @(cd examples/hugo_gitlab && go mod tidy && ../../craft generate --force-all) - @(cd examples/helm && ../../craft generate --force-all) - @(cd examples/nodejs_github && ../../craft generate --force-all) - @(cd examples/nodejs_gitlab && ../../craft generate --force-all) \ No newline at end of file + @(cd examples/generic_github && ../../craft generate) + @(cd examples/generic_gitlab && ../../craft generate) + @(cd examples/golang_github && go mod tidy && ../../craft generate) + @(cd examples/golang_gitlab && go mod tidy && ../../craft generate) + @(cd examples/hugo_github && go mod tidy && ../../craft generate) + @(cd examples/hugo_gitlab && go mod tidy && ../../craft generate) + @(cd examples/helm && ../../craft generate) + @(cd examples/nodejs_github && ../../craft generate) + @(cd examples/nodejs_gitlab && ../../craft generate) \ No newline at end of file diff --git a/testdata/generic/success_bot_github_dependabot/.github/dependabot.yml b/testdata/generic/success_bot_github_dependabot/.github/dependabot.yml deleted file mode 100644 index 92bad2b0..00000000 --- a/testdata/generic/success_bot_github_dependabot/.github/dependabot.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# 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/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - -version: 2 -updates: - - - package-ecosystem: github-actions - directory: / - schedule: - interval: daily - time: "12:00" - timezone: "Etc/UTC" - groups: - major/minor/patch: - update-types: - - major - - minor - - patch - commit-message: - include: scope - prefix: ci - reviewers: - - maintainer name \ No newline at end of file diff --git a/testdata/generic/success_bot_github_dependabot/.github/release.yml b/testdata/generic/success_bot_github_dependabot/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/generic/success_bot_github_dependabot/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/generic/success_bot_github_dependabot/README.md b/testdata/generic/success_bot_github_dependabot/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/generic/success_bot_github_dependabot/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/generic/success_bot_github_renovate/.github/release.yml b/testdata/generic/success_bot_github_renovate/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/generic/success_bot_github_renovate/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/generic/success_bot_github_renovate/README.md b/testdata/generic/success_bot_github_renovate/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/generic/success_bot_github_renovate/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/generic/success_bot_github_renovate/renovate.json5 b/testdata/generic/success_bot_github_renovate/renovate.json5 deleted file mode 100644 index b5a60ee1..00000000 --- a/testdata/generic/success_bot_github_renovate/renovate.json5 +++ /dev/null @@ -1,207 +0,0 @@ -// Code generated by craft; DO NOT EDIT. - -// https://docs.renovatebot.com/configuration-options/ - -{ - "extends": [ ":gitSignOff" ], - "enabled": true, - "branchPrefix": "renovate/", - "labels": [ "dependencies" ], - - "branchConcurrentLimit": 0, - "prConcurrentLimit": 0, - "prCreation": "immediate", - "prHourlyLimit": 0, - - "ignorePaths": [ - "**/bower_components/**", - "**/examples/**", - "**/fixtures/**", - "**/node_modules/**", - "**/test/**", - "**/testdata/**", - "**/tests/**", - ], - - "dependencyDashboard": false, - "osvVulnerabilityAlerts": false, // https://github.com/renovatebot/renovate/discussions/20542 - "forkProcessing": "disabled", - - "minimumReleaseAge": "7 days", - "fetchChangeLogs": "pr", - - "semanticCommits": "auto", - "semanticCommitType": "chore", - "semanticCommitScope": "deps", - - "separateMajorMinor": true, - "separateMinorPatch": false, - "separateMultipleMajor": true, - "separateMultipleMinor": false, - - "baseBranches": [ - "$default", - "/^v[0-9]+\.x/", - "/^v[0-9]+\.[0-9]+\.x/", - ], - - "reviewers": [ - "maintainer name", - ], - "bbUseDefaultReviewers": true, - "gitLabIgnoreApprovals": true, - - "assignAutomerge": true, - "automerge": "false", - "automergeStrategy": "fast-forward", - "automergeType": "pr", - "platformAutomerge": true, - - "rebaseLabel": "rebase", - "rebaseWhen": "behind-base-branch", - "recreateWhen": "auto", - "stopUpdatingLabel": "pause", - - "commitMessageLowerCase": "auto", - "configMigration": false, // removes comments and sets indent to 2 and add a lot of newlines (https://github.com/renovatebot/renovate/issues/16359) - "platformCommit": "auto", - - "goGetDirs": [ "./..." ], - "postUpdateOptions": [ - "gomodTidy", - "gomodUpdateImportPaths", - "helmUpdateSubChartArchives" - ], - "rangeStrategy": "bump", - "updateLockFiles": true, - "useBaseBranchConfig": "none", - - "lockFileMaintenance": { "automerge": true }, - "major": { "automerge": false }, - "minor": { "automerge": true }, - "patch": { "automerge": true }, - "pin": { "automerge": true }, - - "packageRules": [ - { - "addLabels": [ "non-major" ], - "groupName": "cd dependencies (non major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "cd dependencies (major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "ci dependencies (non major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "ci dependencies (major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "golang dependencies (non major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "golang dependencies (major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "js dependencies (non major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "js dependencies (major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "major" ] - }, - ], -} \ No newline at end of file diff --git a/testdata/generic/success_bot_gitlab_renovate/.gitlab-ci.yml b/testdata/generic/success_bot_gitlab_renovate/.gitlab-ci.yml deleted file mode 100644 index 65a829c4..00000000 --- a/testdata/generic/success_bot_gitlab_renovate/.gitlab-ci.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -# RENOVATE_TOKEN: A GitLab access token to allow Renovate crawl your projects. [See doc](https://docs.renovatebot.com/modules/platform/gitlab/#authentication) -# GITHUB_COM_TOKEN: A GitHub access token to allow Renovate fetch changelogs. [See doc](https://docs.renovatebot.com/getting-started/running/#githubcom-token-for-changelogs) - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/generic/success_bot_gitlab_renovate/.gitlab/semrel-plugins.txt b/testdata/generic/success_bot_gitlab_renovate/.gitlab/semrel-plugins.txt deleted file mode 100644 index 9da763d1..00000000 --- a/testdata/generic/success_bot_gitlab_renovate/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,7 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/generic/success_bot_gitlab_renovate/.gitlab/workflows/.gitlab-ci.yml b/testdata/generic/success_bot_gitlab_renovate/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 39c9fd86..00000000 --- a/testdata/generic/success_bot_gitlab_renovate/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,79 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # Renovate template - - project: "to-be-continuous/renovate" - ref: "1" - file: "templates/gitlab-ci-renovate.yml" - -variables: - - RENOVATE_AUTODISCOVER: "true" - RENOVATE_AUTODISCOVER_FILTER: ${CI_PROJECT_PATH} - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -.renovate-rules: &renovate-rules - rules: - # see https://gitlab.com/to-be-continuous/renovate/-/blob/master/templates/gitlab-ci-renovate.yml?ref_type=heads#L348 - # update mode only with schedule triggering - - if: $CI_PIPELINE_SOURCE == 'schedule' - variables: - RENOVATE_DRY_RUN: "false" - # dry run with web triggering - - if: $CI_PIPELINE_SOURCE == 'web' - -renovate-validator: - <<: *renovate-rules - -renovate-depcheck: - <<: *renovate-rules \ No newline at end of file diff --git a/testdata/generic/success_bot_gitlab_renovate/README.md b/testdata/generic/success_bot_gitlab_renovate/README.md deleted file mode 100644 index 87fcdf98..00000000 --- a/testdata/generic/success_bot_gitlab_renovate/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues -

- ---- \ No newline at end of file diff --git a/testdata/generic/success_bot_gitlab_renovate/renovate.json5 b/testdata/generic/success_bot_gitlab_renovate/renovate.json5 deleted file mode 100644 index b5a60ee1..00000000 --- a/testdata/generic/success_bot_gitlab_renovate/renovate.json5 +++ /dev/null @@ -1,207 +0,0 @@ -// Code generated by craft; DO NOT EDIT. - -// https://docs.renovatebot.com/configuration-options/ - -{ - "extends": [ ":gitSignOff" ], - "enabled": true, - "branchPrefix": "renovate/", - "labels": [ "dependencies" ], - - "branchConcurrentLimit": 0, - "prConcurrentLimit": 0, - "prCreation": "immediate", - "prHourlyLimit": 0, - - "ignorePaths": [ - "**/bower_components/**", - "**/examples/**", - "**/fixtures/**", - "**/node_modules/**", - "**/test/**", - "**/testdata/**", - "**/tests/**", - ], - - "dependencyDashboard": false, - "osvVulnerabilityAlerts": false, // https://github.com/renovatebot/renovate/discussions/20542 - "forkProcessing": "disabled", - - "minimumReleaseAge": "7 days", - "fetchChangeLogs": "pr", - - "semanticCommits": "auto", - "semanticCommitType": "chore", - "semanticCommitScope": "deps", - - "separateMajorMinor": true, - "separateMinorPatch": false, - "separateMultipleMajor": true, - "separateMultipleMinor": false, - - "baseBranches": [ - "$default", - "/^v[0-9]+\.x/", - "/^v[0-9]+\.[0-9]+\.x/", - ], - - "reviewers": [ - "maintainer name", - ], - "bbUseDefaultReviewers": true, - "gitLabIgnoreApprovals": true, - - "assignAutomerge": true, - "automerge": "false", - "automergeStrategy": "fast-forward", - "automergeType": "pr", - "platformAutomerge": true, - - "rebaseLabel": "rebase", - "rebaseWhen": "behind-base-branch", - "recreateWhen": "auto", - "stopUpdatingLabel": "pause", - - "commitMessageLowerCase": "auto", - "configMigration": false, // removes comments and sets indent to 2 and add a lot of newlines (https://github.com/renovatebot/renovate/issues/16359) - "platformCommit": "auto", - - "goGetDirs": [ "./..." ], - "postUpdateOptions": [ - "gomodTidy", - "gomodUpdateImportPaths", - "helmUpdateSubChartArchives" - ], - "rangeStrategy": "bump", - "updateLockFiles": true, - "useBaseBranchConfig": "none", - - "lockFileMaintenance": { "automerge": true }, - "major": { "automerge": false }, - "minor": { "automerge": true }, - "patch": { "automerge": true }, - "pin": { "automerge": true }, - - "packageRules": [ - { - "addLabels": [ "non-major" ], - "groupName": "cd dependencies (non major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "cd dependencies (major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "ci dependencies (non major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "ci dependencies (major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "golang dependencies (non major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "golang dependencies (major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "js dependencies (non major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "js dependencies (major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "major" ] - }, - ], -} \ No newline at end of file diff --git a/testdata/generic/success_makefile/Makefile b/testdata/generic/success_makefile/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/generic/success_makefile/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/generic/success_makefile/README.md b/testdata/generic/success_makefile/README.md deleted file mode 100644 index 5d90f12f..00000000 --- a/testdata/generic/success_makefile/README.md +++ /dev/null @@ -1,8 +0,0 @@ - - -# craft - -

-

- ---- \ No newline at end of file diff --git a/testdata/generic/success_makefile/scripts/craft.mk b/testdata/generic/success_makefile/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/generic/success_makefile/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/generic/success_options_github/.github/labeler.yml b/testdata/generic/success_options_github/.github/labeler.yml deleted file mode 100644 index 80a075d4..00000000 --- a/testdata/generic/success_options_github/.github/labeler.yml +++ /dev/null @@ -1,92 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://github.com/marketplace/actions/release-drafter#autolabeler - -autolabeler: - - label: enhancement - title: - - /feat\/.+/ - - /refactor\/.+/ - branch: - - /dev\/.+/ - - - label: breaking - body: - - /.*BREAKING.*/ - - - label: bug - title: - - /fix\/.+/ - - /perf\/.+/ - - /revert\/.+/ - branch: - - /(hot)?fix\/.+/ - - - label: documentation - title: - - /doc(s)?\/.+/ - branch: - - /doc(s)?\/.+/ - files: - - "**/*.md" - - "**/doc.go" - - "**/docs/**" - - - label: chore - title: - - /chore\/.+/ - - - label: test - title: - - /test\/.+/ - branch: - - /test\/.+/ - files: - - "**/*_test.go" - - "**/*.spec.js" - - "**/*.spec.ts" - - "**/*.test.js" - - "**/*.test.ts" - - "**/test/**" - - "**/testdata/**" - - "**/tests/**" - - - label: github_actions - files: - - "action.yml" - - "**/.github/actions/**" - - "**/.github/workflows/**" - - - label: go - files: - - "**/*.go" - - - label: javascript - files: - - "**/*.js" - - "**/*.ts" - - - label: python - files: - - "**/*.py" - - - label: rust - files: - - "**/*.rs" - - - label: shell - files: - - "**/*.sh" - - "**/*.zsh" - - "**/*.bash" - - - label: dependencies - title: - - /.*\(deps\).*/ - # files: - # - "**/go.mod" - # - "**/go.sum" - # - "**/package.json" - -template: | - $CHANGES \ No newline at end of file diff --git a/testdata/generic/success_options_github/.github/release.yml b/testdata/generic/success_options_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/generic/success_options_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/generic/success_options_github/.github/workflows/labeler.yml b/testdata/generic/success_options_github/.github/workflows/labeler.yml deleted file mode 100644 index a729aada..00000000 --- a/testdata/generic/success_options_github/.github/workflows/labeler.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Labeler -run-name: Labeler - -on: - pull_request: # autolabeler on project pull requests - types: - - opened - - reopened - - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize - -jobs: - - labeler: - name: Labeler - runs-on: ubuntu-latest - permissions: - contents: read # enfore rights to specify no release, even draft, is created - pull-requests: write - steps: - # https://github.com/marketplace/actions/release-drafter - - id: drafter - uses: release-drafter/release-drafter@v6 - with: - commitish: ${{ github.base_ref }} - config-name: labeler.yml - latest: false - name: v$RESOLVED_VERSION - prerelease-identifier: labeler - prerelease: true - publish: false - tag: v$RESOLVED_VERSION - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/testdata/generic/success_options_github/README.md b/testdata/generic/success_options_github/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/generic/success_options_github/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/generic/success_options_gitlab/.gitlab-ci.yml b/testdata/generic/success_options_gitlab/.gitlab-ci.yml deleted file mode 100644 index 71988199..00000000 --- a/testdata/generic/success_options_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -# SONAR_TOKEN: SonarQube authentication token (depends on your authentication method) -# SONAR_LOGIN: SonarQube login (depends on your authentication method) -# SONAR_PASSWORD: SonarQube password (depends on your authentication method) - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/generic/success_options_gitlab/.gitlab/semrel-plugins.txt b/testdata/generic/success_options_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index 9da763d1..00000000 --- a/testdata/generic/success_options_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,7 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/generic/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/generic/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 67cf857e..00000000 --- a/testdata/generic/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,68 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # SonarQube template - - project: "to-be-continuous/sonar" - ref: "4" - file: "templates/gitlab-ci-sonar.yml" - -variables: - - SONAR_HOST_URL: "https://sonarcloud.io" - SONAR_BASE_ARGS: | - -Dsonar.properties=sonar.properties - -Dsonar.links.homepage=${CI_PROJECT_URL} - -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines - -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues - SONAR_QUALITY_GATE_ENABLED: "true" - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" \ No newline at end of file diff --git a/testdata/generic/success_options_gitlab/README.md b/testdata/generic/success_options_gitlab/README.md deleted file mode 100644 index 87fcdf98..00000000 --- a/testdata/generic/success_options_gitlab/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues -

- ---- \ No newline at end of file diff --git a/testdata/generic/success_release_gitlab/.gitlab-ci.yml b/testdata/generic/success_release_gitlab/.gitlab-ci.yml deleted file mode 100644 index 37bcd914..00000000 --- a/testdata/generic/success_release_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/generic/success_release_gitlab/.gitlab/semrel-plugins.txt b/testdata/generic/success_release_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index d0ef03ec..00000000 --- a/testdata/generic/success_release_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,8 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits -@kilianpaquier/semantic-release-backmerge \ No newline at end of file diff --git a/testdata/generic/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/generic/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 279a9dff..00000000 --- a/testdata/generic/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,59 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - -variables: - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "false" - SEMREL_AUTO_RELEASE_ENABLED: "true" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -semantic-release: - variables: - GIT_DEPTH: "0" \ No newline at end of file diff --git a/testdata/generic/success_release_gitlab/.releaserc.yml b/testdata/generic/success_release_gitlab/.releaserc.yml deleted file mode 100644 index a00ae481..00000000 --- a/testdata/generic/success_release_gitlab/.releaserc.yml +++ /dev/null @@ -1,97 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://semantic-release.gitbook.io/semantic-release/usage/configuration - -branches: - - (master|main) - - v+([0-9])?(.{+([0-9]),x}).x - - name: next - prerelease: true - - name: beta - prerelease: true - - name: alpha - prerelease: true - - name: staging - prerelease: beta - - name: (dev|develop|development) - prerelease: alpha - -tagFormat: v${version} - -plugins: - - - "@semantic-release/commit-analyzer" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - releaseRules: - - { breaking: true, release: major } - - { revert: true, release: patch } - - { type: feat, release: minor } - - { type: fix, release: patch } - - { type: revert, release: patch } - - { type: perf, release: patch } - - { type: docs, release: patch } - - { type: chore, release: patch } - - { type: refactor, release: minor } - - - { scope: release, release: false } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - - "@semantic-release/release-notes-generator" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - "@semantic-release/changelog" - - - "@semantic-release/git" - - assets: - - CHANGELOG.md - message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - - - "@semantic-release/gitlab" - - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} - failCommentCondition: <% return false; %> - successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 - successCommentCondition: <% return true; %> - assets: - - label: CHANGELOG.md - path: CHANGELOG.md - - - "@kilianpaquier/semantic-release-backmerge" - - targets: - - from: ^(master|main)$ - to: staging - - from: ^(master|main)$ - to: ^(dev|develop|development)$ - - from: staging - to: ^(dev|develop|development)$ - - "@semantic-release/exec" \ No newline at end of file diff --git a/testdata/generic/success_release_gitlab/README.md b/testdata/generic/success_release_gitlab/README.md deleted file mode 100644 index 87fcdf98..00000000 --- a/testdata/generic/success_release_gitlab/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues -

- ---- \ No newline at end of file diff --git a/testdata/generic/success_releases_github/.github/actions/version/action.yml b/testdata/generic/success_releases_github/.github/actions/version/action.yml deleted file mode 100644 index 8b6891ed..00000000 --- a/testdata/generic/success_releases_github/.github/actions/version/action.yml +++ /dev/null @@ -1,96 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - @kilianpaquier/semantic-release-backmerge - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/testdata/generic/success_releases_github/.github/release.yml b/testdata/generic/success_releases_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/generic/success_releases_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/generic/success_releases_github/.github/workflows/release.yml b/testdata/generic/success_releases_github/.github/workflows/release.yml deleted file mode 100644 index e8fc2261..00000000 --- a/testdata/generic/success_releases_github/.github/workflows/release.yml +++ /dev/null @@ -1,75 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - push: - branches: - - main - - master - - v[0-9]+.x - - v[0-9]+.[0-9]+.x - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - permissions: - contents: write - issues: write - pull-requests: write - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - release: - name: Release - runs-on: ubuntu-latest - environment: release - permissions: - contents: write - issues: write - pull-requests: write - needs: - - version - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/testdata/generic/success_releases_github/.releaserc.yml b/testdata/generic/success_releases_github/.releaserc.yml deleted file mode 100644 index 121f3ed1..00000000 --- a/testdata/generic/success_releases_github/.releaserc.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://semantic-release.gitbook.io/semantic-release/usage/configuration - -branches: - - (master|main) - - v+([0-9])?(.{+([0-9]),x}).x - - name: next - prerelease: true - - name: beta - prerelease: true - - name: alpha - prerelease: true - - name: staging - prerelease: beta - - name: (dev|develop|development) - prerelease: alpha - -tagFormat: v${version} - -plugins: - - - "@semantic-release/commit-analyzer" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - releaseRules: - - { breaking: true, release: major } - - { revert: true, release: patch } - - { type: feat, release: minor } - - { type: fix, release: patch } - - { type: revert, release: patch } - - { type: perf, release: patch } - - { type: docs, release: patch } - - { type: chore, release: patch } - - { type: refactor, release: minor } - - - { scope: release, release: false } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - - "@semantic-release/release-notes-generator" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - "@semantic-release/changelog" - - - "@semantic-release/git" - - assets: - - CHANGELOG.md - message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - - - "@semantic-release/github" - - draftRelease: false - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} - failCommentCondition: <% return false; %> - successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 - successCommentCondition: <% return true; %> - assets: - - label: CHANGELOG.md - path: CHANGELOG.md - - - "@kilianpaquier/semantic-release-backmerge" - - targets: - - from: ^(master|main)$ - to: staging - - from: ^(master|main)$ - to: ^(dev|develop|development)$ - - from: staging - to: ^(dev|develop|development)$ - - "@semantic-release/exec" \ No newline at end of file diff --git a/testdata/generic/success_releases_github/README.md b/testdata/generic/success_releases_github/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/generic/success_releases_github/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.dockerignore b/testdata/golang/success_binary_all_github/.dockerignore deleted file mode 100644 index 7555b370..00000000 --- a/testdata/golang/success_binary_all_github/.dockerignore +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# git files -.git -.gitignore - -# basic root files -.editorconfig -.env -.vscode -AUTHORS.md -CONTRIBUTING.md -LICENSE -Makefile -NOTICE -README.md - -# various folders -docs/ -reports/ -dist/ - -# binaries -cli-name -!cli-name/ -cron-* -!cron-*/ -job-* -!job-*/ -worker-* -!worker-*/ - -# test files -**/*_test.go -**/*.test - -# vendor dependencies -vendor/ \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.github/actions/version/action.yml b/testdata/golang/success_binary_all_github/.github/actions/version/action.yml deleted file mode 100644 index 9bd8936d..00000000 --- a/testdata/golang/success_binary_all_github/.github/actions/version/action.yml +++ /dev/null @@ -1,50 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - git fetch --tags - - LAST_TAG=$(git tag --list | sort -V | tail -n1) - - NEXT_TAG=${LAST_TAG-1.0.0} - NEXT_TAG=${NEXT_TAG%-*} - - echo "version=v${NEXT_TAG#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.github/release.yml b/testdata/golang/success_binary_all_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/golang/success_binary_all_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.github/workflows/docker.yml b/testdata/golang/success_binary_all_github/.github/workflows/docker.yml deleted file mode 100644 index 3423fa7c..00000000 --- a/testdata/golang/success_binary_all_github/.github/workflows/docker.yml +++ /dev/null @@ -1,177 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Docker -run-name: Docker - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - workflow_call: - inputs: - release: - description: Whether the docker built image must be propagated to major and minor tags or not - required: false - type: boolean - version: - description: The docker tag to build - required: false - type: string - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - version: - name: Version - runs-on: ubuntu-latest - environment: release - needs: run-workflow - if: ${{ github.event_name != 'pull_request' }} - permissions: - contents: write - issues: write - pull-requests: write - outputs: - release: ${{ steps.version_merge.outputs.release }} - version: ${{ steps.version_merge.outputs.version }} - steps: - - uses: actions/checkout@v4 - - id: version - if: ${{ github.event_name == 'workflow_dispatch' }} - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} - - id: version_merge - run: | - if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then - echo "release=${RELEASE}" >> $GITHUB_OUTPUT - echo "version=${VERSION}" >> $GITHUB_OUTPUT - exit 0 - fi - echo "release=${INPUTS_RELEASE}" >> $GITHUB_OUTPUT - echo "version=${INPUTS_VERSION}" >> $GITHUB_OUTPUT - env: - VERSION: ${{ steps.version.outputs.version }} - RELEASE: ${{ steps.version.outputs.release }} - INPUTS_VERSION: ${{ inputs.version }} - INPUTS_RELEASE: ${{ inputs.release }} - - docker-hadolint: - name: Docker Hadolint - runs-on: ubuntu-latest - needs: run-workflow - permissions: - pull-requests: write - security-events: write - steps: - - uses: actions/checkout@v4 - - uses: hadolint/hadolint-action@v3.1.0 - with: - format: sarif - output-file: hadolint-results.sarif - - if: ${{ ! cancelled() }} - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: hadolint-results.sarif - category: docker-hadolint - - id: hadolint - if: ${{ ! cancelled() }} - uses: hadolint/hadolint-action@v3.1.0 - with: - format: tty - - docker-build: - name: Docker Build - runs-on: ubuntu-latest - environment: docker - needs: - - run-workflow - - version - outputs: - image: ${{ steps.image.outputs.image }} - steps: - - uses: actions/checkout@v4 - - id: image - run: | - IMAGE="example.com/$GITHUB_REPOSITORY" - if [ "$RELEASE" != "true" ]; then - IMAGE="$IMAGE/snapshot" - fi - echo "image=$IMAGE" >> $GITHUB_OUTPUT - env: - RELEASE: ${{ needs.version.outputs.release }} - - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ steps.image.outputs.image }} - labels: | - org.opencontainers.image.created={{date 'YYYY-MM-DDTHH:mm:ssZ'}} - org.opencontainers.image.ref.name="${{ github.ref_name }}" - org.opencontainers.image.version="${{ needs.version.outputs.version }}" - org.opencontainers.image.revision="${{ github.sha }}" - tags: | - type=raw,enable={{is_default_branch}},value=latest - type=semver,enable=true,pattern={{raw}},value=${{ needs.version.outputs.version }} - type=semver,enable=${{ needs.version.outputs.release }},pattern=v{{major}}.{{minor}},value=${{ needs.version.outputs.version }} - type=semver,enable=${{ needs.version.outputs.release }},pattern=v{{major}},value=${{ needs.version.outputs.version }} - - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v3 - with: - registry: example.com - username: ${{ github.repository_owner }} - password: ${{ secrets.REGISTRY_TOKEN }} - - uses: docker/build-push-action@v6 - with: - context: . - labels: ${{ steps.meta.outputs.labels }} - push: true - tags: ${{ steps.meta.outputs.tags }} - - docker-trivy: - name: Docker Trivy - runs-on: ubuntu-latest - environment: docker - permissions: - security-events: write - needs: - - run-workflow - - version - - docker-build - steps: - - uses: aquasecurity/trivy-action@master - with: - format: sarif - ignore-unfixed: false - image-ref: "${{ needs.docker-build.outputs.image }}:${{ needs.version.outputs.version }}" - output: trivy-results.sarif - severity: MEDIUM,HIGH,CRITICAL - env: - TRIVY_USERNAME: ${{ github.repository_owner }} - TRIVY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} - - uses: github/codeql-action/upload-sarif@v3 - with: - category: docker-trivy - sarif_file: trivy-results.sarif - - uses: aquasecurity/trivy-action@master - with: - exit-code: "1" - ignore-unfixed: false - image-ref: "${{ needs.docker-build.outputs.image }}:${{ needs.version.outputs.version }}" - severity: MEDIUM,HIGH,CRITICAL - env: - TRIVY_USERNAME: ${{ github.repository_owner }} - TRIVY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }} \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.github/workflows/golang.yml b/testdata/golang/success_binary_all_github/.github/workflows/golang.yml deleted file mode 100644 index 8cdd3785..00000000 --- a/testdata/golang/success_binary_all_github/.github/workflows/golang.yml +++ /dev/null @@ -1,132 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Golang -run-name: Golang - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - workflow_call: - inputs: - build: - description: Whether to run build job or not - required: false - type: boolean - version: - description: Build version to use in build metadata - required: true - type: string - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - go-vulncheck: - name: Go Vulnerability Check - runs-on: ubuntu-latest - needs: run-workflow - steps: - - uses: golang/govulncheck-action@v1 - with: - check-latest: true - go-package: ./... - go-version-file: go.mod - - go-lint: - name: Go Lint - runs-on: ubuntu-latest - needs: run-workflow - permissions: - checks: write - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - cache: false - check-latest: true - go-version-file: go.mod - token: ${{ secrets.GITHUB_TOKEN }} - - run: mkdir -p reports/ - - uses: golangci/golangci-lint-action@v6 - with: - args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number - - go-test: - name: Go Test - runs-on: ${{ matrix.os }} - needs: run-workflow - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - env: - OS: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - check-latest: true - go-version-file: go.mod - token: ${{ secrets.GITHUB_TOKEN }} - - run: mkdir -p reports/ - - run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - - go-build: - name: Go Build - runs-on: ubuntu-latest - if: ${{ inputs.build }} - needs: - - run-workflow - - go-test - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - check-latest: true - go-version-file: go.mod - token: ${{ secrets.GITHUB_TOKEN }} - # https://github.com/marketplace/actions/goreleaser-action - - uses: goreleaser/goreleaser-action@v6 - with: - args: release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot - env: - VERSION: ${{ inputs.version }} - - uses: actions/upload-artifact@v4 - with: - name: build - # order is important to filter unwanted globs after the filter or desired globs - path: | - dist/* - !dist/*.json - !dist/*.yaml - !dist/*/ - retention-days: 1 \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.gitignore b/testdata/golang/success_binary_all_github/.gitignore deleted file mode 100644 index fad3c940..00000000 --- a/testdata/golang/success_binary_all_github/.gitignore +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries -cli-name -!cli-name/ -cron-* -!cron-*/ -job-* -!job-*/ -worker-* -!worker-*/ \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.golangci.yml b/testdata/golang/success_binary_all_github/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_binary_all_github/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/.goreleaser.yml b/testdata/golang/success_binary_all_github/.goreleaser.yml deleted file mode 100644 index f44d8273..00000000 --- a/testdata/golang/success_binary_all_github/.goreleaser.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -version: 2 - -builds: - - main: cmd/cli-name/main.go - env: - - CGO_ENABLED=0 - ldflags: - - -X example.com/kilianpaquier/craft/internal/cobra.version={{ .Env.VERSION }} - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 - -announce: - skip: true - -changelog: - disable: true - -archives: - - format: tar.gz - wrap_in_directory: false - name_template: >- - {{- .ProjectName }}_ - {{- .Os }}_ - {{- .Arch }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - format_overrides: - - goos: windows - format: zip - -checksum: - name_template: checksums.txt - -nfpms: - - maintainer: maintainer name - license: MIT - file_name_template: >- - {{- .ProjectName }}_ - {{- .Os }}_ - {{- .Arch }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - formats: - - apk - - deb - - rpm \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/Dockerfile b/testdata/golang/success_binary_all_github/Dockerfile deleted file mode 100644 index 7fcfe8ff..00000000 --- a/testdata/golang/success_binary_all_github/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -############################# -# STAGE BUILD # -############################# -FROM golang:1.22 AS build - -WORKDIR /app - -COPY . . - -# hadolint ignore=DL3059 -RUN go mod download -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o cli-name cmd/cli-name/main.go -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o cron-name cmd/cron-name/main.go -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o job-name cmd/job-name/main.go -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o worker-name cmd/worker-name/main.go - -############################# -# STAGE RUN # -############################# -FROM gcr.io/distroless/static-debian12:nonroot - -LABEL org.opencontainers.image.authors="maintainer name" -LABEL org.opencontainers.image.vendor="maintainer name" - -LABEL org.opencontainers.image.title="craft" -LABEL org.opencontainers.image.licenses="MIT" -LABEL org.opencontainers.image.url="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.source="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.documentation="example.com/kilianpaquier/craft" - -WORKDIR /app - -COPY --from=build \ - /app/cli-name \ - /app/cron-name \ - /app/job-name \ - /app/worker-name \ - ./ -COPY launcher.sh launcher.sh - -EXPOSE 5000 - -ENTRYPOINT [ "/app/launcher.sh" ] \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/Makefile b/testdata/golang/success_binary_all_github/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/golang/success_binary_all_github/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/README.md b/testdata/golang/success_binary_all_github/README.md deleted file mode 100644 index c087c0e0..00000000 --- a/testdata/golang/success_binary_all_github/README.md +++ /dev/null @@ -1,13 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - GitHub License - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/launcher.sh b/testdata/golang/success_binary_all_github/launcher.sh deleted file mode 100755 index a6b1317a..00000000 --- a/testdata/golang/success_binary_all_github/launcher.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Code generated by craft; DO NOT EDIT. - -case $BINARY_NAME in - cli-name) /app/cli-name;; - cron-name) /app/cron-name;; - job-name) /app/job-name;; - worker-name) /app/worker-name;; - *) echo "invalid binary '$BINARY_NAME'" && exit 1;; -esac \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/scripts/build.mk b/testdata/golang/success_binary_all_github/scripts/build.mk deleted file mode 100644 index 00e547a5..00000000 --- a/testdata/golang/success_binary_all_github/scripts/build.mk +++ /dev/null @@ -1,44 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - -.PHONY: buildall -buildall: build-cli-name build-cron-name build-job-name build-worker-name - -.PHONY: cli-name cron-name job-name worker-name -build-%: - @CGO_ENABLED=0 go build -o $* cmd/$*/main.go - -.PHONY: cli-name cron-name job-name worker-name -local-%: - @go run cmd/$*/main.go - -.PHONY: build-docker -build-docker: - @docker build -t craft . \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/scripts/craft.mk b/testdata/golang/success_binary_all_github/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/golang/success_binary_all_github/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_binary_all_github/scripts/install.mk b/testdata/golang/success_binary_all_github/scripts/install.mk deleted file mode 100644 index a7835b56..00000000 --- a/testdata/golang/success_binary_all_github/scripts/install.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: - -define install_docker -if which docker >/dev/null; then - echo "docker already installed" - exit 0 -fi - -echo "installing docker" -curl -fsSL https://get.docker.com | bash -dockerd-rootless-setuptool.sh install -endef -.PHONY: install-docker -install-docker: ; @$(value install_docker) -.ONESHELL: \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/.dockerignore b/testdata/golang/success_binary_all_gitlab/.dockerignore deleted file mode 100644 index 7555b370..00000000 --- a/testdata/golang/success_binary_all_gitlab/.dockerignore +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# git files -.git -.gitignore - -# basic root files -.editorconfig -.env -.vscode -AUTHORS.md -CONTRIBUTING.md -LICENSE -Makefile -NOTICE -README.md - -# various folders -docs/ -reports/ -dist/ - -# binaries -cli-name -!cli-name/ -cron-* -!cron-*/ -job-* -!job-*/ -worker-* -!worker-*/ - -# test files -**/*_test.go -**/*.test - -# vendor dependencies -vendor/ \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/.gitignore b/testdata/golang/success_binary_all_gitlab/.gitignore deleted file mode 100644 index fad3c940..00000000 --- a/testdata/golang/success_binary_all_gitlab/.gitignore +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries -cli-name -!cli-name/ -cron-* -!cron-*/ -job-* -!job-*/ -worker-* -!worker-*/ \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/.gitlab-ci.yml b/testdata/golang/success_binary_all_gitlab/.gitlab-ci.yml deleted file mode 100644 index 8b3500bd..00000000 --- a/testdata/golang/success_binary_all_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -# CI_REGISTRY_USER: The user with write access to example.com to push docker images -# CI_REGISTRY_PASSWORD: The user password / token with write access to example.com to push docker images - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/.gitlab/semrel-plugins.txt b/testdata/golang/success_binary_all_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index cd1dcc77..00000000 --- a/testdata/golang/success_binary_all_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,8 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits -semantic-release-license \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/golang/success_binary_all_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 6c1e54b1..00000000 --- a/testdata/golang/success_binary_all_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,104 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # Docker template - - project: "to-be-continuous/docker" - ref: "5" - file: "templates/gitlab-ci-docker.yml" - - # Go template - - project: "to-be-continuous/golang" - ref: "4" - file: "templates/gitlab-ci-golang.yml" - -variables: - - CI_REGISTRY: example.com - - DOCKER_HEALTHCHECK_DISABLED: "true" # https://docs.docker.com/reference/dockerfile/#healthcheck - DOCKER_KANIKO_IMAGE: "gcr.io/kaniko-project/executor:debug" - DOCKER_METADATA: | - --label org.opencontainers.image.created=${CI_JOB_STARTED_AT} - --label org.opencontainers.image.ref.name=${CI_COMMIT_REF_NAME} - --label org.opencontainers.image.revision=${CI_COMMIT_SHA} - --label org.opencontainers.image.version=${SEMREL_INFO_NEXT_VERSION} - DOCKER_RELEASE_EXTRA_TAGS: "latest \\g.\\g \\g> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -go-build: - image: ghcr.io/goreleaser/goreleaser:latest - script: - - goreleaser release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot - artifacts: - name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" - paths: - - dist/ - exclude: - - dist/*.json - - dist/*.yaml - - dist/*/ - expire_in: 1 day \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/.golangci.yml b/testdata/golang/success_binary_all_gitlab/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_binary_all_gitlab/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/.goreleaser.yml b/testdata/golang/success_binary_all_gitlab/.goreleaser.yml deleted file mode 100644 index f44d8273..00000000 --- a/testdata/golang/success_binary_all_gitlab/.goreleaser.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -version: 2 - -builds: - - main: cmd/cli-name/main.go - env: - - CGO_ENABLED=0 - ldflags: - - -X example.com/kilianpaquier/craft/internal/cobra.version={{ .Env.VERSION }} - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 - -announce: - skip: true - -changelog: - disable: true - -archives: - - format: tar.gz - wrap_in_directory: false - name_template: >- - {{- .ProjectName }}_ - {{- .Os }}_ - {{- .Arch }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - format_overrides: - - goos: windows - format: zip - -checksum: - name_template: checksums.txt - -nfpms: - - maintainer: maintainer name - license: MIT - file_name_template: >- - {{- .ProjectName }}_ - {{- .Os }}_ - {{- .Arch }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - formats: - - apk - - deb - - rpm \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/Dockerfile b/testdata/golang/success_binary_all_gitlab/Dockerfile deleted file mode 100644 index 7fcfe8ff..00000000 --- a/testdata/golang/success_binary_all_gitlab/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -############################# -# STAGE BUILD # -############################# -FROM golang:1.22 AS build - -WORKDIR /app - -COPY . . - -# hadolint ignore=DL3059 -RUN go mod download -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o cli-name cmd/cli-name/main.go -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o cron-name cmd/cron-name/main.go -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o job-name cmd/job-name/main.go -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o worker-name cmd/worker-name/main.go - -############################# -# STAGE RUN # -############################# -FROM gcr.io/distroless/static-debian12:nonroot - -LABEL org.opencontainers.image.authors="maintainer name" -LABEL org.opencontainers.image.vendor="maintainer name" - -LABEL org.opencontainers.image.title="craft" -LABEL org.opencontainers.image.licenses="MIT" -LABEL org.opencontainers.image.url="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.source="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.documentation="example.com/kilianpaquier/craft" - -WORKDIR /app - -COPY --from=build \ - /app/cli-name \ - /app/cron-name \ - /app/job-name \ - /app/worker-name \ - ./ -COPY launcher.sh launcher.sh - -EXPOSE 5000 - -ENTRYPOINT [ "/app/launcher.sh" ] \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/Makefile b/testdata/golang/success_binary_all_gitlab/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/golang/success_binary_all_gitlab/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/README.md b/testdata/golang/success_binary_all_gitlab/README.md deleted file mode 100644 index 2fac0c2e..00000000 --- a/testdata/golang/success_binary_all_gitlab/README.md +++ /dev/null @@ -1,13 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues - GitLab License - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/launcher.sh b/testdata/golang/success_binary_all_gitlab/launcher.sh deleted file mode 100755 index a6b1317a..00000000 --- a/testdata/golang/success_binary_all_gitlab/launcher.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Code generated by craft; DO NOT EDIT. - -case $BINARY_NAME in - cli-name) /app/cli-name;; - cron-name) /app/cron-name;; - job-name) /app/job-name;; - worker-name) /app/worker-name;; - *) echo "invalid binary '$BINARY_NAME'" && exit 1;; -esac \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/scripts/build.mk b/testdata/golang/success_binary_all_gitlab/scripts/build.mk deleted file mode 100644 index 00e547a5..00000000 --- a/testdata/golang/success_binary_all_gitlab/scripts/build.mk +++ /dev/null @@ -1,44 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - -.PHONY: buildall -buildall: build-cli-name build-cron-name build-job-name build-worker-name - -.PHONY: cli-name cron-name job-name worker-name -build-%: - @CGO_ENABLED=0 go build -o $* cmd/$*/main.go - -.PHONY: cli-name cron-name job-name worker-name -local-%: - @go run cmd/$*/main.go - -.PHONY: build-docker -build-docker: - @docker build -t craft . \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/scripts/craft.mk b/testdata/golang/success_binary_all_gitlab/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/golang/success_binary_all_gitlab/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_binary_all_gitlab/scripts/install.mk b/testdata/golang/success_binary_all_gitlab/scripts/install.mk deleted file mode 100644 index a7835b56..00000000 --- a/testdata/golang/success_binary_all_gitlab/scripts/install.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: - -define install_docker -if which docker >/dev/null; then - echo "docker already installed" - exit 0 -fi - -echo "installing docker" -curl -fsSL https://get.docker.com | bash -dockerd-rootless-setuptool.sh install -endef -.PHONY: install-docker -install-docker: ; @$(value install_docker) -.ONESHELL: \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/.dockerignore b/testdata/golang/success_binary_cli/.dockerignore deleted file mode 100644 index db8656b7..00000000 --- a/testdata/golang/success_binary_cli/.dockerignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# git files -.git -.gitignore - -# basic root files -.editorconfig -.env -.vscode -AUTHORS.md -CONTRIBUTING.md -LICENSE -Makefile -NOTICE -README.md - -# various folders -docs/ -reports/ -dist/ - -# binaries -cli-name -!cli-name/ - -# test files -**/*_test.go -**/*.test - -# vendor dependencies -vendor/ \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/.gitignore b/testdata/golang/success_binary_cli/.gitignore deleted file mode 100644 index 38bd86bd..00000000 --- a/testdata/golang/success_binary_cli/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries -cli-name -!cli-name/ \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/.golangci.yml b/testdata/golang/success_binary_cli/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_binary_cli/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/.goreleaser.yml b/testdata/golang/success_binary_cli/.goreleaser.yml deleted file mode 100644 index b8892700..00000000 --- a/testdata/golang/success_binary_cli/.goreleaser.yml +++ /dev/null @@ -1,50 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -version: 2 - -builds: - - main: cmd/cli-name/main.go - env: - - CGO_ENABLED=0 - ldflags: - - -X example.com/kilianpaquier/craft/internal/cobra.version={{ .Env.VERSION }} - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 - -announce: - skip: true - -changelog: - disable: true - -archives: - - format: tar.gz - wrap_in_directory: false - name_template: >- - {{- .ProjectName }}_ - {{- .Os }}_ - {{- .Arch }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - format_overrides: - - goos: windows - format: zip - -checksum: - name_template: checksums.txt - -nfpms: - - maintainer: maintainer name - file_name_template: >- - {{- .ProjectName }}_ - {{- .Os }}_ - {{- .Arch }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - formats: - - apk - - deb - - rpm \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/Dockerfile b/testdata/golang/success_binary_cli/Dockerfile deleted file mode 100644 index b74c0137..00000000 --- a/testdata/golang/success_binary_cli/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -############################# -# STAGE BUILD # -############################# -FROM golang:1.22 AS build - -WORKDIR /app - -COPY . . - -# hadolint ignore=DL3059 -RUN go mod download -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o cli-name cmd/cli-name/main.go - -############################# -# STAGE RUN # -############################# -FROM gcr.io/distroless/static-debian12:nonroot - -LABEL org.opencontainers.image.authors="maintainer name" -LABEL org.opencontainers.image.vendor="maintainer name" - -LABEL org.opencontainers.image.title="craft" -LABEL org.opencontainers.image.url="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.source="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.documentation="example.com/kilianpaquier/craft" - -WORKDIR /app - -COPY --from=build \ - /app/cli-name \ - ./ - -EXPOSE 3000 - -ENTRYPOINT [ "/app/cli-name" ] \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/Makefile b/testdata/golang/success_binary_cli/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/golang/success_binary_cli/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/README.md b/testdata/golang/success_binary_cli/README.md deleted file mode 100644 index 23c71413..00000000 --- a/testdata/golang/success_binary_cli/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/scripts/build.mk b/testdata/golang/success_binary_cli/scripts/build.mk deleted file mode 100644 index f3abfc51..00000000 --- a/testdata/golang/success_binary_cli/scripts/build.mk +++ /dev/null @@ -1,44 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - -.PHONY: buildall -buildall: build-cli-name - -.PHONY: cli-name -build-%: - @CGO_ENABLED=0 go build -o $* cmd/$*/main.go - -.PHONY: cli-name -local-%: - @go run cmd/$*/main.go - -.PHONY: build-docker -build-docker: - @docker build -t craft . \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/scripts/craft.mk b/testdata/golang/success_binary_cli/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/golang/success_binary_cli/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_binary_cli/scripts/install.mk b/testdata/golang/success_binary_cli/scripts/install.mk deleted file mode 100644 index a7835b56..00000000 --- a/testdata/golang/success_binary_cli/scripts/install.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: - -define install_docker -if which docker >/dev/null; then - echo "docker already installed" - exit 0 -fi - -echo "installing docker" -curl -fsSL https://get.docker.com | bash -dockerd-rootless-setuptool.sh install -endef -.PHONY: install-docker -install-docker: ; @$(value install_docker) -.ONESHELL: \ No newline at end of file diff --git a/testdata/golang/success_binary_cron/.dockerignore b/testdata/golang/success_binary_cron/.dockerignore deleted file mode 100644 index 71af1539..00000000 --- a/testdata/golang/success_binary_cron/.dockerignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# git files -.git -.gitignore - -# basic root files -.editorconfig -.env -.vscode -AUTHORS.md -CONTRIBUTING.md -LICENSE -Makefile -NOTICE -README.md - -# various folders -docs/ -reports/ -dist/ - -# binaries -cron-* -!cron-*/ - -# test files -**/*_test.go -**/*.test - -# vendor dependencies -vendor/ \ No newline at end of file diff --git a/testdata/golang/success_binary_cron/.gitignore b/testdata/golang/success_binary_cron/.gitignore deleted file mode 100644 index 744a68c9..00000000 --- a/testdata/golang/success_binary_cron/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries -cron-* -!cron-*/ \ No newline at end of file diff --git a/testdata/golang/success_binary_cron/.golangci.yml b/testdata/golang/success_binary_cron/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_binary_cron/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_binary_cron/Dockerfile b/testdata/golang/success_binary_cron/Dockerfile deleted file mode 100644 index 8ad70040..00000000 --- a/testdata/golang/success_binary_cron/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -############################# -# STAGE BUILD # -############################# -FROM golang:1.22 AS build - -WORKDIR /app - -COPY . . - -# hadolint ignore=DL3059 -RUN go mod download -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o cron-name cmd/cron-name/main.go - -############################# -# STAGE RUN # -############################# -FROM gcr.io/distroless/static-debian12:nonroot - -LABEL org.opencontainers.image.authors="maintainer name" -LABEL org.opencontainers.image.vendor="maintainer name" - -LABEL org.opencontainers.image.title="craft" -LABEL org.opencontainers.image.url="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.source="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.documentation="example.com/kilianpaquier/craft" - -WORKDIR /app - -COPY --from=build \ - /app/cron-name \ - ./ - -EXPOSE 3000 - -ENTRYPOINT [ "/app/cron-name" ] \ No newline at end of file diff --git a/testdata/golang/success_binary_cron/Makefile b/testdata/golang/success_binary_cron/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/golang/success_binary_cron/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/golang/success_binary_cron/README.md b/testdata/golang/success_binary_cron/README.md deleted file mode 100644 index 23c71413..00000000 --- a/testdata/golang/success_binary_cron/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_binary_cron/scripts/craft.mk b/testdata/golang/success_binary_cron/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/golang/success_binary_cron/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_binary_job/.dockerignore b/testdata/golang/success_binary_job/.dockerignore deleted file mode 100644 index 1b93af7a..00000000 --- a/testdata/golang/success_binary_job/.dockerignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# git files -.git -.gitignore - -# basic root files -.editorconfig -.env -.vscode -AUTHORS.md -CONTRIBUTING.md -LICENSE -Makefile -NOTICE -README.md - -# various folders -docs/ -reports/ -dist/ - -# binaries -job-* -!job-*/ - -# test files -**/*_test.go -**/*.test - -# vendor dependencies -vendor/ \ No newline at end of file diff --git a/testdata/golang/success_binary_job/.gitignore b/testdata/golang/success_binary_job/.gitignore deleted file mode 100644 index 82969677..00000000 --- a/testdata/golang/success_binary_job/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries -job-* -!job-*/ \ No newline at end of file diff --git a/testdata/golang/success_binary_job/.golangci.yml b/testdata/golang/success_binary_job/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_binary_job/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_binary_job/Dockerfile b/testdata/golang/success_binary_job/Dockerfile deleted file mode 100644 index c9f8ae99..00000000 --- a/testdata/golang/success_binary_job/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -############################# -# STAGE BUILD # -############################# -FROM golang:1.22 AS build - -WORKDIR /app - -COPY . . - -# hadolint ignore=DL3059 -RUN go mod download -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o job-name cmd/job-name/main.go - -############################# -# STAGE RUN # -############################# -FROM gcr.io/distroless/static-debian12:nonroot - -LABEL org.opencontainers.image.authors="maintainer name" -LABEL org.opencontainers.image.vendor="maintainer name" - -LABEL org.opencontainers.image.title="craft" -LABEL org.opencontainers.image.url="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.source="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.documentation="example.com/kilianpaquier/craft" - -WORKDIR /app - -COPY --from=build \ - /app/job-name \ - ./ - -EXPOSE 3000 - -ENTRYPOINT [ "/app/job-name" ] \ No newline at end of file diff --git a/testdata/golang/success_binary_job/Makefile b/testdata/golang/success_binary_job/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/golang/success_binary_job/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/golang/success_binary_job/README.md b/testdata/golang/success_binary_job/README.md deleted file mode 100644 index 23c71413..00000000 --- a/testdata/golang/success_binary_job/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_binary_job/scripts/build.mk b/testdata/golang/success_binary_job/scripts/build.mk deleted file mode 100644 index d9e6b4c0..00000000 --- a/testdata/golang/success_binary_job/scripts/build.mk +++ /dev/null @@ -1,44 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - -.PHONY: buildall -buildall: build-job-name - -.PHONY: job-name -build-%: - @CGO_ENABLED=0 go build -o $* cmd/$*/main.go - -.PHONY: job-name -local-%: - @go run cmd/$*/main.go - -.PHONY: build-docker -build-docker: - @docker build -t craft . \ No newline at end of file diff --git a/testdata/golang/success_binary_job/scripts/craft.mk b/testdata/golang/success_binary_job/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/golang/success_binary_job/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_binary_job/scripts/install.mk b/testdata/golang/success_binary_job/scripts/install.mk deleted file mode 100644 index a7835b56..00000000 --- a/testdata/golang/success_binary_job/scripts/install.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: - -define install_docker -if which docker >/dev/null; then - echo "docker already installed" - exit 0 -fi - -echo "installing docker" -curl -fsSL https://get.docker.com | bash -dockerd-rootless-setuptool.sh install -endef -.PHONY: install-docker -install-docker: ; @$(value install_docker) -.ONESHELL: \ No newline at end of file diff --git a/testdata/golang/success_binary_none/.gitignore b/testdata/golang/success_binary_none/.gitignore deleted file mode 100644 index 51c2c8b1..00000000 --- a/testdata/golang/success_binary_none/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries \ No newline at end of file diff --git a/testdata/golang/success_binary_none/.golangci.yml b/testdata/golang/success_binary_none/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_binary_none/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_binary_none/Makefile b/testdata/golang/success_binary_none/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/golang/success_binary_none/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/golang/success_binary_none/README.md b/testdata/golang/success_binary_none/README.md deleted file mode 100644 index 23c71413..00000000 --- a/testdata/golang/success_binary_none/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_binary_none/scripts/build.mk b/testdata/golang/success_binary_none/scripts/build.mk deleted file mode 100644 index 273e333c..00000000 --- a/testdata/golang/success_binary_none/scripts/build.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s \ No newline at end of file diff --git a/testdata/golang/success_binary_none/scripts/craft.mk b/testdata/golang/success_binary_none/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/golang/success_binary_none/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_binary_none/scripts/install.mk b/testdata/golang/success_binary_none/scripts/install.mk deleted file mode 100644 index 3438dfbb..00000000 --- a/testdata/golang/success_binary_none/scripts/install.mk +++ /dev/null @@ -1,24 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/.dockerignore b/testdata/golang/success_binary_worker/.dockerignore deleted file mode 100644 index 42396729..00000000 --- a/testdata/golang/success_binary_worker/.dockerignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# git files -.git -.gitignore - -# basic root files -.editorconfig -.env -.vscode -AUTHORS.md -CONTRIBUTING.md -LICENSE -Makefile -NOTICE -README.md - -# various folders -docs/ -reports/ -dist/ - -# binaries -worker-* -!worker-*/ - -# test files -**/*_test.go -**/*.test - -# vendor dependencies -vendor/ \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/.gitignore b/testdata/golang/success_binary_worker/.gitignore deleted file mode 100644 index d8cf8064..00000000 --- a/testdata/golang/success_binary_worker/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries -worker-* -!worker-*/ \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/.golangci.yml b/testdata/golang/success_binary_worker/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_binary_worker/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/Dockerfile b/testdata/golang/success_binary_worker/Dockerfile deleted file mode 100644 index 8e98bff4..00000000 --- a/testdata/golang/success_binary_worker/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -############################# -# STAGE BUILD # -############################# -FROM golang:1.22 AS build - -WORKDIR /app - -COPY . . - -# hadolint ignore=DL3059 -RUN go mod download -# hadolint ignore=DL3059 -RUN CGO_ENABLED=0 go build -o worker-name cmd/worker-name/main.go - -############################# -# STAGE RUN # -############################# -FROM gcr.io/distroless/static-debian12:nonroot - -LABEL org.opencontainers.image.authors="maintainer name" -LABEL org.opencontainers.image.vendor="maintainer name" - -LABEL org.opencontainers.image.title="craft" -LABEL org.opencontainers.image.url="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.source="example.com/kilianpaquier/craft" -LABEL org.opencontainers.image.documentation="example.com/kilianpaquier/craft" - -WORKDIR /app - -COPY --from=build \ - /app/worker-name \ - ./ - -EXPOSE 3000 - -ENTRYPOINT [ "/app/worker-name" ] \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/Makefile b/testdata/golang/success_binary_worker/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/golang/success_binary_worker/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/README.md b/testdata/golang/success_binary_worker/README.md deleted file mode 100644 index 23c71413..00000000 --- a/testdata/golang/success_binary_worker/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/scripts/build.mk b/testdata/golang/success_binary_worker/scripts/build.mk deleted file mode 100644 index 4f0b5649..00000000 --- a/testdata/golang/success_binary_worker/scripts/build.mk +++ /dev/null @@ -1,44 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - -.PHONY: buildall -buildall: build-worker-name - -.PHONY: worker-name -build-%: - @CGO_ENABLED=0 go build -o $* cmd/$*/main.go - -.PHONY: worker-name -local-%: - @go run cmd/$*/main.go - -.PHONY: build-docker -build-docker: - @docker build -t craft . \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/scripts/craft.mk b/testdata/golang/success_binary_worker/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/golang/success_binary_worker/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_binary_worker/scripts/install.mk b/testdata/golang/success_binary_worker/scripts/install.mk deleted file mode 100644 index a7835b56..00000000 --- a/testdata/golang/success_binary_worker/scripts/install.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: - -define install_docker -if which docker >/dev/null; then - echo "docker already installed" - exit 0 -fi - -echo "installing docker" -curl -fsSL https://get.docker.com | bash -dockerd-rootless-setuptool.sh install -endef -.PHONY: install-docker -install-docker: ; @$(value install_docker) -.ONESHELL: \ No newline at end of file diff --git a/testdata/golang/success_bot_github_dependabot/.github/dependabot.yml b/testdata/golang/success_bot_github_dependabot/.github/dependabot.yml deleted file mode 100644 index 56853829..00000000 --- a/testdata/golang/success_bot_github_dependabot/.github/dependabot.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# 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/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - -version: 2 -updates: - - - package-ecosystem: github-actions - directory: / - schedule: - interval: daily - time: "12:00" - timezone: "Etc/UTC" - groups: - major/minor/patch: - update-types: - - major - - minor - - patch - commit-message: - include: scope - prefix: ci - reviewers: - - maintainer name - - package-ecosystem: gomod - directory: / - schedule: - interval: daily - time: "12:00" - timezone: "Etc/UTC" - groups: - minor/patch: - update-types: - - minor - - patch - commit-message: - include: scope - prefix: chore - reviewers: - - maintainer name \ No newline at end of file diff --git a/testdata/golang/success_bot_github_dependabot/.github/release.yml b/testdata/golang/success_bot_github_dependabot/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/golang/success_bot_github_dependabot/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/golang/success_bot_github_dependabot/.gitignore b/testdata/golang/success_bot_github_dependabot/.gitignore deleted file mode 100644 index 51c2c8b1..00000000 --- a/testdata/golang/success_bot_github_dependabot/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries \ No newline at end of file diff --git a/testdata/golang/success_bot_github_dependabot/.golangci.yml b/testdata/golang/success_bot_github_dependabot/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_bot_github_dependabot/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_bot_github_dependabot/README.md b/testdata/golang/success_bot_github_dependabot/README.md deleted file mode 100644 index e9a9ac25..00000000 --- a/testdata/golang/success_bot_github_dependabot/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_bot_github_renovate/.github/release.yml b/testdata/golang/success_bot_github_renovate/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/golang/success_bot_github_renovate/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/golang/success_bot_github_renovate/.gitignore b/testdata/golang/success_bot_github_renovate/.gitignore deleted file mode 100644 index 51c2c8b1..00000000 --- a/testdata/golang/success_bot_github_renovate/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries \ No newline at end of file diff --git a/testdata/golang/success_bot_github_renovate/.golangci.yml b/testdata/golang/success_bot_github_renovate/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_bot_github_renovate/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_bot_github_renovate/README.md b/testdata/golang/success_bot_github_renovate/README.md deleted file mode 100644 index e9a9ac25..00000000 --- a/testdata/golang/success_bot_github_renovate/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_bot_github_renovate/renovate.json5 b/testdata/golang/success_bot_github_renovate/renovate.json5 deleted file mode 100644 index b5a60ee1..00000000 --- a/testdata/golang/success_bot_github_renovate/renovate.json5 +++ /dev/null @@ -1,207 +0,0 @@ -// Code generated by craft; DO NOT EDIT. - -// https://docs.renovatebot.com/configuration-options/ - -{ - "extends": [ ":gitSignOff" ], - "enabled": true, - "branchPrefix": "renovate/", - "labels": [ "dependencies" ], - - "branchConcurrentLimit": 0, - "prConcurrentLimit": 0, - "prCreation": "immediate", - "prHourlyLimit": 0, - - "ignorePaths": [ - "**/bower_components/**", - "**/examples/**", - "**/fixtures/**", - "**/node_modules/**", - "**/test/**", - "**/testdata/**", - "**/tests/**", - ], - - "dependencyDashboard": false, - "osvVulnerabilityAlerts": false, // https://github.com/renovatebot/renovate/discussions/20542 - "forkProcessing": "disabled", - - "minimumReleaseAge": "7 days", - "fetchChangeLogs": "pr", - - "semanticCommits": "auto", - "semanticCommitType": "chore", - "semanticCommitScope": "deps", - - "separateMajorMinor": true, - "separateMinorPatch": false, - "separateMultipleMajor": true, - "separateMultipleMinor": false, - - "baseBranches": [ - "$default", - "/^v[0-9]+\.x/", - "/^v[0-9]+\.[0-9]+\.x/", - ], - - "reviewers": [ - "maintainer name", - ], - "bbUseDefaultReviewers": true, - "gitLabIgnoreApprovals": true, - - "assignAutomerge": true, - "automerge": "false", - "automergeStrategy": "fast-forward", - "automergeType": "pr", - "platformAutomerge": true, - - "rebaseLabel": "rebase", - "rebaseWhen": "behind-base-branch", - "recreateWhen": "auto", - "stopUpdatingLabel": "pause", - - "commitMessageLowerCase": "auto", - "configMigration": false, // removes comments and sets indent to 2 and add a lot of newlines (https://github.com/renovatebot/renovate/issues/16359) - "platformCommit": "auto", - - "goGetDirs": [ "./..." ], - "postUpdateOptions": [ - "gomodTidy", - "gomodUpdateImportPaths", - "helmUpdateSubChartArchives" - ], - "rangeStrategy": "bump", - "updateLockFiles": true, - "useBaseBranchConfig": "none", - - "lockFileMaintenance": { "automerge": true }, - "major": { "automerge": false }, - "minor": { "automerge": true }, - "patch": { "automerge": true }, - "pin": { "automerge": true }, - - "packageRules": [ - { - "addLabels": [ "non-major" ], - "groupName": "cd dependencies (non major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "cd dependencies (major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "ci dependencies (non major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "ci dependencies (major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "golang dependencies (non major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "golang dependencies (major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "js dependencies (non major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "js dependencies (major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "major" ] - }, - ], -} \ No newline at end of file diff --git a/testdata/golang/success_options_github/.codecov.yml b/testdata/golang/success_options_github/.codecov.yml deleted file mode 100644 index 417ec071..00000000 --- a/testdata/golang/success_options_github/.codecov.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -coverage: - precision: 2 - round: down - range: 85...100 - - status: - project: - default: - threshold: 2.5% - patch: - default: - threshold: 2.5% - -ignore: - - "cmd" - - "examples" - - "**/cobra/**" - - "**/mocks/**" - - "**/tests/**" - - "**/testutils/**" \ No newline at end of file diff --git a/testdata/golang/success_options_github/.github/labeler.yml b/testdata/golang/success_options_github/.github/labeler.yml deleted file mode 100644 index 80a075d4..00000000 --- a/testdata/golang/success_options_github/.github/labeler.yml +++ /dev/null @@ -1,92 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://github.com/marketplace/actions/release-drafter#autolabeler - -autolabeler: - - label: enhancement - title: - - /feat\/.+/ - - /refactor\/.+/ - branch: - - /dev\/.+/ - - - label: breaking - body: - - /.*BREAKING.*/ - - - label: bug - title: - - /fix\/.+/ - - /perf\/.+/ - - /revert\/.+/ - branch: - - /(hot)?fix\/.+/ - - - label: documentation - title: - - /doc(s)?\/.+/ - branch: - - /doc(s)?\/.+/ - files: - - "**/*.md" - - "**/doc.go" - - "**/docs/**" - - - label: chore - title: - - /chore\/.+/ - - - label: test - title: - - /test\/.+/ - branch: - - /test\/.+/ - files: - - "**/*_test.go" - - "**/*.spec.js" - - "**/*.spec.ts" - - "**/*.test.js" - - "**/*.test.ts" - - "**/test/**" - - "**/testdata/**" - - "**/tests/**" - - - label: github_actions - files: - - "action.yml" - - "**/.github/actions/**" - - "**/.github/workflows/**" - - - label: go - files: - - "**/*.go" - - - label: javascript - files: - - "**/*.js" - - "**/*.ts" - - - label: python - files: - - "**/*.py" - - - label: rust - files: - - "**/*.rs" - - - label: shell - files: - - "**/*.sh" - - "**/*.zsh" - - "**/*.bash" - - - label: dependencies - title: - - /.*\(deps\).*/ - # files: - # - "**/go.mod" - # - "**/go.sum" - # - "**/package.json" - -template: | - $CHANGES \ No newline at end of file diff --git a/testdata/golang/success_options_github/.github/release.yml b/testdata/golang/success_options_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/golang/success_options_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/golang/success_options_github/.github/workflows/codeql.yml b/testdata/golang/success_options_github/.github/workflows/codeql.yml deleted file mode 100644 index 6a8c85d1..00000000 --- a/testdata/golang/success_options_github/.github/workflows/codeql.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: CodeQL -run-name: CodeQL - -on: - push: - branches: - - alpha - - beta - - dev - - develop - - development - - main - - master - - next - - staging - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - -jobs: - codeql: - name: CodeQL - runs-on: ubuntu-latest - permissions: - security-events: write - strategy: - fail-fast: false - matrix: - language: - - go - steps: - - uses: actions/checkout@v4 - - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - - uses: github/codeql-action/autobuild@v3 - - uses: github/codeql-action/analyze@v3 - with: - category: /language:${{ matrix.language }} \ No newline at end of file diff --git a/testdata/golang/success_options_github/.github/workflows/golang.yml b/testdata/golang/success_options_github/.github/workflows/golang.yml deleted file mode 100644 index b51f4429..00000000 --- a/testdata/golang/success_options_github/.github/workflows/golang.yml +++ /dev/null @@ -1,158 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Golang -run-name: Golang - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - workflow_call: - inputs: - version: - description: Build version to use in build metadata - required: true - type: string - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - go-vulncheck: - name: Go Vulnerability Check - runs-on: ubuntu-latest - needs: run-workflow - steps: - - uses: golang/govulncheck-action@v1 - with: - check-latest: true - go-package: ./... - go-version-file: go.mod - - go-lint: - name: Go Lint - runs-on: ubuntu-latest - needs: run-workflow - permissions: - checks: write - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - cache: false - check-latest: true - go-version-file: go.mod - token: ${{ secrets.GITHUB_TOKEN }} - - run: mkdir -p reports/ - - uses: golangci/golangci-lint-action@v6 - with: - args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number - - uses: actions/upload-artifact@v4 - with: - name: lint - path: reports - retention-days: 1 - - go-test: - name: Go Test - runs-on: ${{ matrix.os }} - needs: run-workflow - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - env: - OS: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - check-latest: true - go-version-file: go.mod - token: ${{ secrets.GITHUB_TOKEN }} - - run: mkdir -p reports/ - - run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s - - if: ${{ ! startsWith(github.head_ref, 'dependabot') && ! startsWith(github.head_ref, 'renovate') }} - uses: codecov/codecov-action@v4 - with: - codecov_yml_path: .codecov.yml - disable_search: true - env_vars: OS - fail_ci_if_error: false - files: reports/go-coverage.native.out - flags: ${{ matrix.os }} - slug: ${{ github.repository }} - token: ${{ secrets.CODECOV_TOKEN }} - - uses: actions/upload-artifact@v4 - with: - name: coverage - path: reports - retention-days: 1 - - sonar-analysis: - name: Sonar Analysis - runs-on: ubuntu-latest - needs: - - run-workflow - - go-lint - - go-test - env: - SONAR_USER_HOME: .sonar - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/download-artifact@v4 - with: - merge-multiple: true - path: reports - - uses: actions/cache@v4 - with: - path: ${{ env.SONAR_USER_HOME }} - key: sonar-cache - - uses: sonarsource/sonarcloud-github-action@master - if: ${{ github.event_name == 'pull_request' }} - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: | - -Dproject.settings=sonar.properties - -Dsonar.pullrequest.base=${{ github.base_ref }} - -Dsonar.pullrequest.branch=${{ github.head_ref }} - -Dsonar.pullrequest.key=${{ github.event.issue.number }} - - uses: sonarsource/sonarcloud-github-action@master - if: ${{ github.event_name == 'push' }} - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: | - -Dproject.settings=sonar.properties - -Dsonar.branch.name=${{ github.ref_name }} \ No newline at end of file diff --git a/testdata/golang/success_options_github/.github/workflows/labeler.yml b/testdata/golang/success_options_github/.github/workflows/labeler.yml deleted file mode 100644 index a729aada..00000000 --- a/testdata/golang/success_options_github/.github/workflows/labeler.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Labeler -run-name: Labeler - -on: - pull_request: # autolabeler on project pull requests - types: - - opened - - reopened - - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize - -jobs: - - labeler: - name: Labeler - runs-on: ubuntu-latest - permissions: - contents: read # enfore rights to specify no release, even draft, is created - pull-requests: write - steps: - # https://github.com/marketplace/actions/release-drafter - - id: drafter - uses: release-drafter/release-drafter@v6 - with: - commitish: ${{ github.base_ref }} - config-name: labeler.yml - latest: false - name: v$RESOLVED_VERSION - prerelease-identifier: labeler - prerelease: true - publish: false - tag: v$RESOLVED_VERSION - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/testdata/golang/success_options_github/.gitignore b/testdata/golang/success_options_github/.gitignore deleted file mode 100644 index 51c2c8b1..00000000 --- a/testdata/golang/success_options_github/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries \ No newline at end of file diff --git a/testdata/golang/success_options_github/.golangci.yml b/testdata/golang/success_options_github/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_options_github/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_options_github/README.md b/testdata/golang/success_options_github/README.md deleted file mode 100644 index 2cd7b1fa..00000000 --- a/testdata/golang/success_options_github/README.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Coverage - Coverage - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_options_github/sonar.properties b/testdata/golang/success_options_github/sonar.properties deleted file mode 100644 index f861a4e1..00000000 --- a/testdata/golang/success_options_github/sonar.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -sonar.host.url=https://sonarcloud.io -sonar.qualitygate.wait=true - -sonar.organization=maintainer name -sonar.projectBaseDir=. -sonar.projectKey=kilianpaquier_craft -sonar.projectName=craft - -sonar.exclusions=**/examples/**,**/testdata/**,**/vendor/** -sonar.coverage.exclusions=cmd/**,**/cobra/**,**/tests/**,**/testutils/** -sonar.test.inclusions=**/*_test.go -sonar.go.coverage.reportPaths=reports/go-coverage.native.out -sonar.go.golangci-lint.reportPaths=reports/go-ci-lint.checkstyle.xml \ No newline at end of file diff --git a/testdata/golang/success_options_gitlab/.gitignore b/testdata/golang/success_options_gitlab/.gitignore deleted file mode 100644 index 51c2c8b1..00000000 --- a/testdata/golang/success_options_gitlab/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries \ No newline at end of file diff --git a/testdata/golang/success_options_gitlab/.gitlab-ci.yml b/testdata/golang/success_options_gitlab/.gitlab-ci.yml deleted file mode 100644 index 71988199..00000000 --- a/testdata/golang/success_options_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -# SONAR_TOKEN: SonarQube authentication token (depends on your authentication method) -# SONAR_LOGIN: SonarQube login (depends on your authentication method) -# SONAR_PASSWORD: SonarQube password (depends on your authentication method) - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/golang/success_options_gitlab/.gitlab/semrel-plugins.txt b/testdata/golang/success_options_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index 9da763d1..00000000 --- a/testdata/golang/success_options_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,7 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/golang/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/golang/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 18f80267..00000000 --- a/testdata/golang/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,84 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # Go template - - project: "to-be-continuous/golang" - ref: "4" - file: "templates/gitlab-ci-golang.yml" - - # SonarQube template - - project: "to-be-continuous/sonar" - ref: "4" - file: "templates/gitlab-ci-sonar.yml" - -variables: - - GO_CI_LINT_ARGS: "--config .golangci.yml --timeout 240s --fast --sort-results" - GO_CI_LINT_IMAGE: "registry.hub.docker.com/golangci/golangci-lint:latest-alpine" - GO_IMAGE: "registry.hub.docker.com/library/golang:latest" - GO_OUTDATED_DISABLED: "false" # https://github.com/psampaz/go-mod-outdated - GO_SBOM_DISABLED: "true" - GO_TEST_FLAGS: "-coverpkg=./... -covermode=count" - GO_TEST_IMAGE: "registry.hub.docker.com/library/golang:latest" - - SONAR_HOST_URL: "https://sonarcloud.io" - SONAR_BASE_ARGS: | - -Dsonar.properties=sonar.properties - -Dsonar.links.homepage=${CI_PROJECT_URL} - -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines - -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues - SONAR_QUALITY_GATE_ENABLED: "true" - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -go-build: - when: never \ No newline at end of file diff --git a/testdata/golang/success_options_gitlab/.golangci.yml b/testdata/golang/success_options_gitlab/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_options_gitlab/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_options_gitlab/README.md b/testdata/golang/success_options_gitlab/README.md deleted file mode 100644 index 080426ff..00000000 --- a/testdata/golang/success_options_gitlab/README.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues - Coverage - Coverage - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_options_gitlab/sonar.properties b/testdata/golang/success_options_gitlab/sonar.properties deleted file mode 100644 index 5ce2374c..00000000 --- a/testdata/golang/success_options_gitlab/sonar.properties +++ /dev/null @@ -1,17 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -sonar.host.url=https://sonarcloud.io -sonar.qualitygate.wait=true - -sonar.organization=maintainer name -sonar.projectBaseDir=. -sonar.projectKey=kilianpaquier_craft -sonar.projectName=craft - -sonar.exclusions=**/examples/**,**/testdata/**,**/vendor/** -sonar.coverage.exclusions=cmd/**,**/cobra/**,**/tests/**,**/testutils/** -sonar.test.inclusions=**/*_test.go - -sonar.go.tests.reportPaths=reports/go-test.native.json -sonar.go.coverage.reportPaths=reports/go-coverage.native.out -sonar.go.golangci-lint.reportPaths=reports/go-ci-lint.checkstyle.xml \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/.gitignore b/testdata/golang/success_release_gitlab/.gitignore deleted file mode 100644 index 51c2c8b1..00000000 --- a/testdata/golang/success_release_gitlab/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/.gitlab-ci.yml b/testdata/golang/success_release_gitlab/.gitlab-ci.yml deleted file mode 100644 index 37bcd914..00000000 --- a/testdata/golang/success_release_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/.gitlab/semrel-plugins.txt b/testdata/golang/success_release_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index d0ef03ec..00000000 --- a/testdata/golang/success_release_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,8 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits -@kilianpaquier/semantic-release-backmerge \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/golang/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index e7f06bb5..00000000 --- a/testdata/golang/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,75 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # Go template - - project: "to-be-continuous/golang" - ref: "4" - file: "templates/gitlab-ci-golang.yml" - -variables: - - GO_CI_LINT_ARGS: "--config .golangci.yml --timeout 240s --fast --sort-results" - GO_CI_LINT_IMAGE: "registry.hub.docker.com/golangci/golangci-lint:latest-alpine" - GO_IMAGE: "registry.hub.docker.com/library/golang:latest" - GO_OUTDATED_DISABLED: "false" # https://github.com/psampaz/go-mod-outdated - GO_SBOM_DISABLED: "true" - GO_TEST_FLAGS: "-coverpkg=./... -covermode=count" - GO_TEST_IMAGE: "registry.hub.docker.com/library/golang:latest" - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "false" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -semantic-release: - variables: - GIT_DEPTH: "0" - -go-build: - when: never \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/.golangci.yml b/testdata/golang/success_release_gitlab/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_release_gitlab/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/.releaserc.yml b/testdata/golang/success_release_gitlab/.releaserc.yml deleted file mode 100644 index a00ae481..00000000 --- a/testdata/golang/success_release_gitlab/.releaserc.yml +++ /dev/null @@ -1,97 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://semantic-release.gitbook.io/semantic-release/usage/configuration - -branches: - - (master|main) - - v+([0-9])?(.{+([0-9]),x}).x - - name: next - prerelease: true - - name: beta - prerelease: true - - name: alpha - prerelease: true - - name: staging - prerelease: beta - - name: (dev|develop|development) - prerelease: alpha - -tagFormat: v${version} - -plugins: - - - "@semantic-release/commit-analyzer" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - releaseRules: - - { breaking: true, release: major } - - { revert: true, release: patch } - - { type: feat, release: minor } - - { type: fix, release: patch } - - { type: revert, release: patch } - - { type: perf, release: patch } - - { type: docs, release: patch } - - { type: chore, release: patch } - - { type: refactor, release: minor } - - - { scope: release, release: false } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - - "@semantic-release/release-notes-generator" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - "@semantic-release/changelog" - - - "@semantic-release/git" - - assets: - - CHANGELOG.md - message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - - - "@semantic-release/gitlab" - - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} - failCommentCondition: <% return false; %> - successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 - successCommentCondition: <% return true; %> - assets: - - label: CHANGELOG.md - path: CHANGELOG.md - - - "@kilianpaquier/semantic-release-backmerge" - - targets: - - from: ^(master|main)$ - to: staging - - from: ^(master|main)$ - to: ^(dev|develop|development)$ - - from: staging - to: ^(dev|develop|development)$ - - "@semantic-release/exec" \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/Makefile b/testdata/golang/success_release_gitlab/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/golang/success_release_gitlab/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/README.md b/testdata/golang/success_release_gitlab/README.md deleted file mode 100644 index 7d64b9e4..00000000 --- a/testdata/golang/success_release_gitlab/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/scripts/build.mk b/testdata/golang/success_release_gitlab/scripts/build.mk deleted file mode 100644 index 273e333c..00000000 --- a/testdata/golang/success_release_gitlab/scripts/build.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/scripts/craft.mk b/testdata/golang/success_release_gitlab/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/golang/success_release_gitlab/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/golang/success_release_gitlab/scripts/install.mk b/testdata/golang/success_release_gitlab/scripts/install.mk deleted file mode 100644 index 3438dfbb..00000000 --- a/testdata/golang/success_release_gitlab/scripts/install.mk +++ /dev/null @@ -1,24 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: \ No newline at end of file diff --git a/testdata/golang/success_releases_github/.github/actions/version/action.yml b/testdata/golang/success_releases_github/.github/actions/version/action.yml deleted file mode 100644 index 8b6891ed..00000000 --- a/testdata/golang/success_releases_github/.github/actions/version/action.yml +++ /dev/null @@ -1,96 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - @kilianpaquier/semantic-release-backmerge - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/testdata/golang/success_releases_github/.github/release.yml b/testdata/golang/success_releases_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/golang/success_releases_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/golang/success_releases_github/.github/workflows/golang.yml b/testdata/golang/success_releases_github/.github/workflows/golang.yml deleted file mode 100644 index a8804d65..00000000 --- a/testdata/golang/success_releases_github/.github/workflows/golang.yml +++ /dev/null @@ -1,97 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Golang -run-name: Golang - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - workflow_call: - inputs: - version: - description: Build version to use in build metadata - required: true - type: string - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - go-vulncheck: - name: Go Vulnerability Check - runs-on: ubuntu-latest - needs: run-workflow - steps: - - uses: golang/govulncheck-action@v1 - with: - check-latest: true - go-package: ./... - go-version-file: go.mod - - go-lint: - name: Go Lint - runs-on: ubuntu-latest - needs: run-workflow - permissions: - checks: write - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - cache: false - check-latest: true - go-version-file: go.mod - token: ${{ secrets.GITHUB_TOKEN }} - - run: mkdir -p reports/ - - uses: golangci/golangci-lint-action@v6 - with: - args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number - - go-test: - name: Go Test - runs-on: ${{ matrix.os }} - needs: run-workflow - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - env: - OS: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - check-latest: true - go-version-file: go.mod - token: ${{ secrets.GITHUB_TOKEN }} - - run: mkdir -p reports/ - - run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s \ No newline at end of file diff --git a/testdata/golang/success_releases_github/.github/workflows/release.yml b/testdata/golang/success_releases_github/.github/workflows/release.yml deleted file mode 100644 index d18c2f98..00000000 --- a/testdata/golang/success_releases_github/.github/workflows/release.yml +++ /dev/null @@ -1,74 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - persist-credentials: false - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.RELEASE_TOKEN }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - golang: - name: Golang - needs: version - uses: ./.github/workflows/golang.yml - permissions: - checks: write - with: - version: ${{ needs.version.outputs.version }} - secrets: inherit - - release: - name: Release - runs-on: ubuntu-latest - environment: release - needs: - - version - - golang - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - persist-credentials: false - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ secrets.RELEASE_TOKEN }} \ No newline at end of file diff --git a/testdata/golang/success_releases_github/.gitignore b/testdata/golang/success_releases_github/.gitignore deleted file mode 100644 index 51c2c8b1..00000000 --- a/testdata/golang/success_releases_github/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries \ No newline at end of file diff --git a/testdata/golang/success_releases_github/.golangci.yml b/testdata/golang/success_releases_github/.golangci.yml deleted file mode 100644 index e571b8cc..00000000 --- a/testdata/golang/success_releases_github/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(example.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/golang/success_releases_github/.releaserc.yml b/testdata/golang/success_releases_github/.releaserc.yml deleted file mode 100644 index 121f3ed1..00000000 --- a/testdata/golang/success_releases_github/.releaserc.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://semantic-release.gitbook.io/semantic-release/usage/configuration - -branches: - - (master|main) - - v+([0-9])?(.{+([0-9]),x}).x - - name: next - prerelease: true - - name: beta - prerelease: true - - name: alpha - prerelease: true - - name: staging - prerelease: beta - - name: (dev|develop|development) - prerelease: alpha - -tagFormat: v${version} - -plugins: - - - "@semantic-release/commit-analyzer" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - releaseRules: - - { breaking: true, release: major } - - { revert: true, release: patch } - - { type: feat, release: minor } - - { type: fix, release: patch } - - { type: revert, release: patch } - - { type: perf, release: patch } - - { type: docs, release: patch } - - { type: chore, release: patch } - - { type: refactor, release: minor } - - - { scope: release, release: false } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - - "@semantic-release/release-notes-generator" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - "@semantic-release/changelog" - - - "@semantic-release/git" - - assets: - - CHANGELOG.md - message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - - - "@semantic-release/github" - - draftRelease: false - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} - failCommentCondition: <% return false; %> - successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 - successCommentCondition: <% return true; %> - assets: - - label: CHANGELOG.md - path: CHANGELOG.md - - - "@kilianpaquier/semantic-release-backmerge" - - targets: - - from: ^(master|main)$ - to: staging - - from: ^(master|main)$ - to: ^(dev|develop|development)$ - - from: staging - to: ^(dev|develop|development)$ - - "@semantic-release/exec" \ No newline at end of file diff --git a/testdata/golang/success_releases_github/README.md b/testdata/golang/success_releases_github/README.md deleted file mode 100644 index e9a9ac25..00000000 --- a/testdata/golang/success_releases_github/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/.craft b/testdata/helm/success_dependencies/chart/.craft deleted file mode 100644 index 4d4481f8..00000000 --- a/testdata/helm/success_dependencies/chart/.craft +++ /dev/null @@ -1,13 +0,0 @@ -# Helm values overrides configuration ---- -dependencies: - - name: dependency-name - version: v0.1.0 - repository: http://example.com/dependency-name - values: - key: value - key_with_sub_keys: - key: value - - name: second-dependency-name - version: v0.1.0 - repository: http://example.com/second-dependency-name diff --git a/testdata/helm/success_dependencies/chart/.helmignore b/testdata/helm/success_dependencies/chart/.helmignore deleted file mode 100644 index d5eeda75..00000000 --- a/testdata/helm/success_dependencies/chart/.helmignore +++ /dev/null @@ -1,28 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store - -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ - -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ - -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/Chart.yaml b/testdata/helm/success_dependencies/chart/Chart.yaml deleted file mode 100644 index ba9c1eaf..00000000 --- a/testdata/helm/success_dependencies/chart/Chart.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -apiVersion: v2 -name: craft -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "0.1.0" - -dependencies: - - name: dependency-name - version: v0.1.0 - repository: http://example.com/dependency-name - - name: second-dependency-name - version: v0.1.0 - repository: http://example.com/second-dependency-name - -maintainers: - - name: maintainer name diff --git a/testdata/helm/success_dependencies/chart/charts/.gitkeep b/testdata/helm/success_dependencies/chart/charts/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/testdata/helm/success_dependencies/chart/templates/_helpers.tpl b/testdata/helm/success_dependencies/chart/templates/_helpers.tpl deleted file mode 100644 index 1661bfe7..00000000 --- a/testdata/helm/success_dependencies/chart/templates/_helpers.tpl +++ /dev/null @@ -1,64 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{/* -Expand the name of the chart. -*/}} -{{- define "craft.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "craft.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "craft.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "craft.labels" -}} -helm.sh/chart: {{ include "craft.chart" . }} -{{ include "craft.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "craft.selectorLabels" -}} -app.kubernetes.io/name: {{ include "craft.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "craft.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "craft.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/testdata/helm/success_dependencies/chart/templates/configmap.yaml b/testdata/helm/success_dependencies/chart/templates/configmap.yaml deleted file mode 100644 index d334cbbb..00000000 --- a/testdata/helm/success_dependencies/chart/templates/configmap.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} - -{{ range $name, $config := merge .Values.crons .Values.jobs .Values.workers }} -{{ with $config.configMap }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ print $fullname "-" $name }} -data: -{{- range .tpl_folders }} -{{- range $path, $_ := $.Files.Glob (print . "/**") }} - {{ base $path }}: |- - {{ tpl ($.Files.Get $path) . }} -{{- end }} -{{- end }} - -{{- range .include_folders }} -{{- range $path, $_ := $.Files.Glob (print . "/**") }} - {{ base $path }}: |- - {{ $.Files.Get $path }} -{{- end }} -{{- end }} - -{{- if .data }} - {{- toYaml (tpl .data .) | nindent 2 }} -{{- end }} -{{ end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/templates/cronjob.yaml b/testdata/helm/success_dependencies/chart/templates/cronjob.yaml deleted file mode 100644 index ee146003..00000000 --- a/testdata/helm/success_dependencies/chart/templates/cronjob.yaml +++ /dev/null @@ -1,104 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.crons }} -apiVersion: batch/v1beta1 -kind: CronJob -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - suspend: {{ $config.suspend }} - schedule: {{ $config.schedule | quote }} - concurrencyPolicy: {{ $config.concurrencyPolicy }} - failedJobsHistoryLimit: {{ $config.failedJobsHistoryLimit }} - successfulJobsHistoryLimit: {{ $config.successfulJobsHistoryLimit }} - jobTemplate: - spec: - completionMode: {{ $config.completionMode }} - completions: {{ $config.completions }} - parallelism: {{ $config.parallelism }} - selector: - matchLabels: - {{- $selectorLabels | nindent 10 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 12 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 12 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 12 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 12 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 16 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 16 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 16 }} - {{- end }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 16 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 12 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/templates/deployment.yaml b/testdata/helm/success_dependencies/chart/templates/deployment.yaml deleted file mode 100644 index ce640a6a..00000000 --- a/testdata/helm/success_dependencies/chart/templates/deployment.yaml +++ /dev/null @@ -1,114 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.workers }} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - paused: {{ $config.paused }} - {{- if not $config.autoscaling.enabled }} - replicas: {{ $config.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- $selectorLabels | nindent 6 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 8 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 8 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 12 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - ports: - - name: http - containerPort: {{ $config.service.port }} - protocol: TCP - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - {{- with $config.livenessProbe }} - livenessProbe: - {{- toYaml $config.livenessProbe | nindent 12 }} - {{- end }} - {{- with $config.readinessProbe }} - readinessProbe: - {{- toYaml $config.readinessProbe | nindent 12 }} - {{- end }} - {{- with $config.startupProbe }} - startupProbe: - {{- toYaml $config.startupProbe | nindent 12 }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 12 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/templates/hpa.yaml b/testdata/helm/success_dependencies/chart/templates/hpa.yaml deleted file mode 100644 index c6c8d9a6..00000000 --- a/testdata/helm/success_dependencies/chart/templates/hpa.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} - -{{ range $name, $config := .Values.workers }} -{{- if $config.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ print $fullname "-" $name }} - minReplicas: {{ $config.autoscaling.minReplicas }} - maxReplicas: {{ $config.autoscaling.maxReplicas }} - metrics: - {{- toYaml $config.autoscaling.metrics | nindent 4 }} -{{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/templates/job.yaml b/testdata/helm/success_dependencies/chart/templates/job.yaml deleted file mode 100644 index b476f534..00000000 --- a/testdata/helm/success_dependencies/chart/templates/job.yaml +++ /dev/null @@ -1,102 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.jobs }} -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ print $fullname "-" $name }} - namespace: default - labels: - {{- $labels | nindent 4 }} -spec: - suspend: {{ $config.suspend }} - completionMode: {{ $config.completionMode }} - completions: {{ $config.completions }} - parallelism: {{ $config.parallelism }} - {{- with $config.ttlSecondsAfterFinished }} - ttlSecondsAfterFinished: {{ . }} - {{- end }} - selector: - matchLabels: - {{- $selectorLabels | nindent 6 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 8 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 8 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 12 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 12 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/templates/service.yaml b/testdata/helm/success_dependencies/chart/templates/service.yaml deleted file mode 100644 index 61dfa73d..00000000 --- a/testdata/helm/success_dependencies/chart/templates/service.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} - -{{ range $name, $config := .Values.workers }} -apiVersion: v1 -kind: Service -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - type: ClusterIP - ports: - - port: {{ $config.env.BINARY_PORT | default 3000 }} - targetPort: http - protocol: TCP - name: http - selector: - {{- $selectorLabels | nindent 4 }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_dependencies/chart/templates/serviceaccount.yaml b/testdata/helm/success_dependencies/chart/templates/serviceaccount.yaml deleted file mode 100644 index e0f0a202..00000000 --- a/testdata/helm/success_dependencies/chart/templates/serviceaccount.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} - -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ $serviceAccountName }} - labels: - {{- $labels | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/testdata/helm/success_empty_values/chart/.craft b/testdata/helm/success_empty_values/chart/.craft deleted file mode 100644 index 4641bece..00000000 --- a/testdata/helm/success_empty_values/chart/.craft +++ /dev/null @@ -1,2 +0,0 @@ -# Helm values overrides configuration ---- diff --git a/testdata/helm/success_empty_values/chart/.helmignore b/testdata/helm/success_empty_values/chart/.helmignore deleted file mode 100644 index d5eeda75..00000000 --- a/testdata/helm/success_empty_values/chart/.helmignore +++ /dev/null @@ -1,28 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store - -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ - -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ - -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ \ No newline at end of file diff --git a/testdata/helm/success_empty_values/chart/Chart.yaml b/testdata/helm/success_empty_values/chart/Chart.yaml deleted file mode 100644 index 913821a2..00000000 --- a/testdata/helm/success_empty_values/chart/Chart.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -apiVersion: v2 -name: craft -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "0.1.0" - -dependencies: [] - -maintainers: - - name: maintainer name diff --git a/testdata/helm/success_empty_values/chart/charts/.gitkeep b/testdata/helm/success_empty_values/chart/charts/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/testdata/helm/success_empty_values/chart/templates/_helpers.tpl b/testdata/helm/success_empty_values/chart/templates/_helpers.tpl deleted file mode 100644 index 1661bfe7..00000000 --- a/testdata/helm/success_empty_values/chart/templates/_helpers.tpl +++ /dev/null @@ -1,64 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{/* -Expand the name of the chart. -*/}} -{{- define "craft.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "craft.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "craft.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "craft.labels" -}} -helm.sh/chart: {{ include "craft.chart" . }} -{{ include "craft.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "craft.selectorLabels" -}} -app.kubernetes.io/name: {{ include "craft.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "craft.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "craft.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/testdata/helm/success_empty_values/chart/templates/configmap.yaml b/testdata/helm/success_empty_values/chart/templates/configmap.yaml deleted file mode 100644 index d334cbbb..00000000 --- a/testdata/helm/success_empty_values/chart/templates/configmap.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} - -{{ range $name, $config := merge .Values.crons .Values.jobs .Values.workers }} -{{ with $config.configMap }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ print $fullname "-" $name }} -data: -{{- range .tpl_folders }} -{{- range $path, $_ := $.Files.Glob (print . "/**") }} - {{ base $path }}: |- - {{ tpl ($.Files.Get $path) . }} -{{- end }} -{{- end }} - -{{- range .include_folders }} -{{- range $path, $_ := $.Files.Glob (print . "/**") }} - {{ base $path }}: |- - {{ $.Files.Get $path }} -{{- end }} -{{- end }} - -{{- if .data }} - {{- toYaml (tpl .data .) | nindent 2 }} -{{- end }} -{{ end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_empty_values/chart/templates/cronjob.yaml b/testdata/helm/success_empty_values/chart/templates/cronjob.yaml deleted file mode 100644 index ee146003..00000000 --- a/testdata/helm/success_empty_values/chart/templates/cronjob.yaml +++ /dev/null @@ -1,104 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.crons }} -apiVersion: batch/v1beta1 -kind: CronJob -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - suspend: {{ $config.suspend }} - schedule: {{ $config.schedule | quote }} - concurrencyPolicy: {{ $config.concurrencyPolicy }} - failedJobsHistoryLimit: {{ $config.failedJobsHistoryLimit }} - successfulJobsHistoryLimit: {{ $config.successfulJobsHistoryLimit }} - jobTemplate: - spec: - completionMode: {{ $config.completionMode }} - completions: {{ $config.completions }} - parallelism: {{ $config.parallelism }} - selector: - matchLabels: - {{- $selectorLabels | nindent 10 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 12 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 12 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 12 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 12 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 16 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 16 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 16 }} - {{- end }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 16 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 12 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_empty_values/chart/templates/deployment.yaml b/testdata/helm/success_empty_values/chart/templates/deployment.yaml deleted file mode 100644 index ce640a6a..00000000 --- a/testdata/helm/success_empty_values/chart/templates/deployment.yaml +++ /dev/null @@ -1,114 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.workers }} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - paused: {{ $config.paused }} - {{- if not $config.autoscaling.enabled }} - replicas: {{ $config.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- $selectorLabels | nindent 6 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 8 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 8 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 12 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - ports: - - name: http - containerPort: {{ $config.service.port }} - protocol: TCP - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - {{- with $config.livenessProbe }} - livenessProbe: - {{- toYaml $config.livenessProbe | nindent 12 }} - {{- end }} - {{- with $config.readinessProbe }} - readinessProbe: - {{- toYaml $config.readinessProbe | nindent 12 }} - {{- end }} - {{- with $config.startupProbe }} - startupProbe: - {{- toYaml $config.startupProbe | nindent 12 }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 12 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_empty_values/chart/templates/hpa.yaml b/testdata/helm/success_empty_values/chart/templates/hpa.yaml deleted file mode 100644 index c6c8d9a6..00000000 --- a/testdata/helm/success_empty_values/chart/templates/hpa.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} - -{{ range $name, $config := .Values.workers }} -{{- if $config.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ print $fullname "-" $name }} - minReplicas: {{ $config.autoscaling.minReplicas }} - maxReplicas: {{ $config.autoscaling.maxReplicas }} - metrics: - {{- toYaml $config.autoscaling.metrics | nindent 4 }} -{{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_empty_values/chart/templates/job.yaml b/testdata/helm/success_empty_values/chart/templates/job.yaml deleted file mode 100644 index b476f534..00000000 --- a/testdata/helm/success_empty_values/chart/templates/job.yaml +++ /dev/null @@ -1,102 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.jobs }} -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ print $fullname "-" $name }} - namespace: default - labels: - {{- $labels | nindent 4 }} -spec: - suspend: {{ $config.suspend }} - completionMode: {{ $config.completionMode }} - completions: {{ $config.completions }} - parallelism: {{ $config.parallelism }} - {{- with $config.ttlSecondsAfterFinished }} - ttlSecondsAfterFinished: {{ . }} - {{- end }} - selector: - matchLabels: - {{- $selectorLabels | nindent 6 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 8 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 8 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 12 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 12 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_empty_values/chart/templates/service.yaml b/testdata/helm/success_empty_values/chart/templates/service.yaml deleted file mode 100644 index 61dfa73d..00000000 --- a/testdata/helm/success_empty_values/chart/templates/service.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} - -{{ range $name, $config := .Values.workers }} -apiVersion: v1 -kind: Service -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - type: ClusterIP - ports: - - port: {{ $config.env.BINARY_PORT | default 3000 }} - targetPort: http - protocol: TCP - name: http - selector: - {{- $selectorLabels | nindent 4 }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_empty_values/chart/templates/serviceaccount.yaml b/testdata/helm/success_empty_values/chart/templates/serviceaccount.yaml deleted file mode 100644 index e0f0a202..00000000 --- a/testdata/helm/success_empty_values/chart/templates/serviceaccount.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} - -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ $serviceAccountName }} - labels: - {{- $labels | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/testdata/helm/success_empty_values/chart/values.yaml b/testdata/helm/success_empty_values/chart/values.yaml deleted file mode 100644 index c34b786d..00000000 --- a/testdata/helm/success_empty_values/chart/values.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -imagePullSecrets: [] - -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: false - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -############################################# -# all cronjobs # -############################################# -crons: {} - -############################################# -# all jobs # -############################################# -jobs: {} - -############################################# -# all workers # -############################################# -workers: {} - -############################################# -# all dependencies # -############################################# \ No newline at end of file diff --git a/testdata/helm/success_resources/chart/.craft b/testdata/helm/success_resources/chart/.craft deleted file mode 100644 index 4641bece..00000000 --- a/testdata/helm/success_resources/chart/.craft +++ /dev/null @@ -1,2 +0,0 @@ -# Helm values overrides configuration ---- diff --git a/testdata/helm/success_resources/chart/.helmignore b/testdata/helm/success_resources/chart/.helmignore deleted file mode 100644 index d5eeda75..00000000 --- a/testdata/helm/success_resources/chart/.helmignore +++ /dev/null @@ -1,28 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store - -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ - -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ - -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ \ No newline at end of file diff --git a/testdata/helm/success_resources/chart/Chart.yaml b/testdata/helm/success_resources/chart/Chart.yaml deleted file mode 100644 index 913821a2..00000000 --- a/testdata/helm/success_resources/chart/Chart.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -apiVersion: v2 -name: craft -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "0.1.0" - -dependencies: [] - -maintainers: - - name: maintainer name diff --git a/testdata/helm/success_resources/chart/charts/.gitkeep b/testdata/helm/success_resources/chart/charts/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/testdata/helm/success_resources/chart/templates/_helpers.tpl b/testdata/helm/success_resources/chart/templates/_helpers.tpl deleted file mode 100644 index 1661bfe7..00000000 --- a/testdata/helm/success_resources/chart/templates/_helpers.tpl +++ /dev/null @@ -1,64 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{/* -Expand the name of the chart. -*/}} -{{- define "craft.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "craft.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "craft.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "craft.labels" -}} -helm.sh/chart: {{ include "craft.chart" . }} -{{ include "craft.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "craft.selectorLabels" -}} -app.kubernetes.io/name: {{ include "craft.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "craft.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "craft.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/testdata/helm/success_resources/chart/templates/configmap.yaml b/testdata/helm/success_resources/chart/templates/configmap.yaml deleted file mode 100644 index d334cbbb..00000000 --- a/testdata/helm/success_resources/chart/templates/configmap.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} - -{{ range $name, $config := merge .Values.crons .Values.jobs .Values.workers }} -{{ with $config.configMap }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ print $fullname "-" $name }} -data: -{{- range .tpl_folders }} -{{- range $path, $_ := $.Files.Glob (print . "/**") }} - {{ base $path }}: |- - {{ tpl ($.Files.Get $path) . }} -{{- end }} -{{- end }} - -{{- range .include_folders }} -{{- range $path, $_ := $.Files.Glob (print . "/**") }} - {{ base $path }}: |- - {{ $.Files.Get $path }} -{{- end }} -{{- end }} - -{{- if .data }} - {{- toYaml (tpl .data .) | nindent 2 }} -{{- end }} -{{ end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_resources/chart/templates/cronjob.yaml b/testdata/helm/success_resources/chart/templates/cronjob.yaml deleted file mode 100644 index ee146003..00000000 --- a/testdata/helm/success_resources/chart/templates/cronjob.yaml +++ /dev/null @@ -1,104 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.crons }} -apiVersion: batch/v1beta1 -kind: CronJob -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - suspend: {{ $config.suspend }} - schedule: {{ $config.schedule | quote }} - concurrencyPolicy: {{ $config.concurrencyPolicy }} - failedJobsHistoryLimit: {{ $config.failedJobsHistoryLimit }} - successfulJobsHistoryLimit: {{ $config.successfulJobsHistoryLimit }} - jobTemplate: - spec: - completionMode: {{ $config.completionMode }} - completions: {{ $config.completions }} - parallelism: {{ $config.parallelism }} - selector: - matchLabels: - {{- $selectorLabels | nindent 10 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 12 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 12 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 12 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 12 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 16 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 16 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 16 }} - {{- end }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 16 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 12 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_resources/chart/templates/deployment.yaml b/testdata/helm/success_resources/chart/templates/deployment.yaml deleted file mode 100644 index ce640a6a..00000000 --- a/testdata/helm/success_resources/chart/templates/deployment.yaml +++ /dev/null @@ -1,114 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.workers }} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - paused: {{ $config.paused }} - {{- if not $config.autoscaling.enabled }} - replicas: {{ $config.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- $selectorLabels | nindent 6 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 8 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 8 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 12 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - ports: - - name: http - containerPort: {{ $config.service.port }} - protocol: TCP - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - {{- with $config.livenessProbe }} - livenessProbe: - {{- toYaml $config.livenessProbe | nindent 12 }} - {{- end }} - {{- with $config.readinessProbe }} - readinessProbe: - {{- toYaml $config.readinessProbe | nindent 12 }} - {{- end }} - {{- with $config.startupProbe }} - startupProbe: - {{- toYaml $config.startupProbe | nindent 12 }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 12 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_resources/chart/templates/hpa.yaml b/testdata/helm/success_resources/chart/templates/hpa.yaml deleted file mode 100644 index c6c8d9a6..00000000 --- a/testdata/helm/success_resources/chart/templates/hpa.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} - -{{ range $name, $config := .Values.workers }} -{{- if $config.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ print $fullname "-" $name }} - minReplicas: {{ $config.autoscaling.minReplicas }} - maxReplicas: {{ $config.autoscaling.maxReplicas }} - metrics: - {{- toYaml $config.autoscaling.metrics | nindent 4 }} -{{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_resources/chart/templates/job.yaml b/testdata/helm/success_resources/chart/templates/job.yaml deleted file mode 100644 index b476f534..00000000 --- a/testdata/helm/success_resources/chart/templates/job.yaml +++ /dev/null @@ -1,102 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.jobs }} -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ print $fullname "-" $name }} - namespace: default - labels: - {{- $labels | nindent 4 }} -spec: - suspend: {{ $config.suspend }} - completionMode: {{ $config.completionMode }} - completions: {{ $config.completions }} - parallelism: {{ $config.parallelism }} - {{- with $config.ttlSecondsAfterFinished }} - ttlSecondsAfterFinished: {{ . }} - {{- end }} - selector: - matchLabels: - {{- $selectorLabels | nindent 6 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 8 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 8 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 12 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 12 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_resources/chart/templates/service.yaml b/testdata/helm/success_resources/chart/templates/service.yaml deleted file mode 100644 index 61dfa73d..00000000 --- a/testdata/helm/success_resources/chart/templates/service.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} - -{{ range $name, $config := .Values.workers }} -apiVersion: v1 -kind: Service -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - type: ClusterIP - ports: - - port: {{ $config.env.BINARY_PORT | default 3000 }} - targetPort: http - protocol: TCP - name: http - selector: - {{- $selectorLabels | nindent 4 }} -{{ end }} \ No newline at end of file diff --git a/testdata/helm/success_resources/chart/templates/serviceaccount.yaml b/testdata/helm/success_resources/chart/templates/serviceaccount.yaml deleted file mode 100644 index e0f0a202..00000000 --- a/testdata/helm/success_resources/chart/templates/serviceaccount.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} - -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ $serviceAccountName }} - labels: - {{- $labels | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/testdata/helm/success_resources/chart/values.yaml b/testdata/helm/success_resources/chart/values.yaml deleted file mode 100644 index 68e83386..00000000 --- a/testdata/helm/success_resources/chart/values.yaml +++ /dev/null @@ -1,369 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -imagePullSecrets: [] - -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: false - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -############################################# -# all cronjobs # -############################################# -crons: - cron-name: - suspend: true - schedule: "*/1 * * * *" - concurrencyPolicy: Forbid - completionMode: NonIndexed - completions: 1 - parallelism: 1 - image: - registry: "" - repository: kilianpaquier/craft - pullPolicy: "" - # Overrides the image tag whose default is the chart appVersion. - tag: "" - env: - BINARY_NAME: cron-name - BINARY_PORT: 5000 - envFrom: [] - # - prefix: "" - # configMapRef: - # name: "" - # secretRef: - # name: "" - resources: - limits: - cpu: 250m - memory: 256Mi - storage: 10Gi - requests: - cpu: 50m - memory: 128Mi - storage: 5Gi - failedJobsHistoryLimit: 1 - successfulJobsHistoryLimit: 3 - restartPolicy: OnFailure - configMap: {} - # mountPath: /etc/config/ - # tpl_folders: # folders to be included in configmap with tpl - # - folder_name - # include_folders: # folders to be included in configmap without tpl - # - folder_name - # data: - # name: value - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#volume-v1-core - volumes: [] - # - name: "" - # configMap: - # name: configMapName - # - name: "" - # emptyDir: - # medium: "" - # sizeLimit: 1Gi - # - name: "" - # persistentVolumeClaim: - # claimName: "" - # readOnly: false - # - name: "" - # secret: - # secretName: "" - volumeMounts: [] - # - mountPath: /etc/config/ - # name: volume[*].name - # readOnly: true - - podAnnotations: {} - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#podsecuritycontext-v1-core - podSecurityContext: {} - # fsGroup: 2 - # fsGroupChangePolicy: Always | OnRootMismatch - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#securitycontext-v1-core - securityContext: {} - # allowPrivilegeEscalation: false - # capabilities: - # add: [] - # drop: [] - # privileged: false - # readOnlyRootFilesystem: true - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#nodeselector-v1-core - nodeSelector: {} - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#toleration-v1-core - tolerations: [] - # - effect: NoSchedule | PreferNoSchedule | NoExecute - # key: "" - # operator: Exists | Equal - # tolerationSeconds: 600 - # value: "" - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#affinity-v1-core - affinity: {} - - -############################################# -# all jobs # -############################################# -jobs: - job-name: - suspend: true - completionMode: NonIndexed - completions: 1 - parallelism: 1 - image: - registry: "" - repository: kilianpaquier/craft - pullPolicy: "" - # Overrides the image tag whose default is the chart appVersion. - tag: "" - env: - BINARY_NAME: job-name - BINARY_PORT: 5000 - envFrom: [] - # - prefix: "" - # configMapRef: - # name: "" - # secretRef: - # name: "" - resources: - limits: - cpu: 250m - memory: 256Mi - storage: 10Gi - requests: - cpu: 50m - memory: 128Mi - storage: 5Gi - restartPolicy: OnFailure - configMap: {} - # mountPath: /etc/config/ - # tpl_folders: # folders to be included in configmap with tpl - # - folder_name - # include_folders: # folders to be included in configmap without tpl - # - folder_name - # data: - # name: value - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#volume-v1-core - volumes: [] - # - name: "" - # configMap: - # name: configMapName - # - name: "" - # emptyDir: - # medium: "" - # sizeLimit: 1Gi - # - name: "" - # persistentVolumeClaim: - # claimName: "" - # readOnly: false - # - name: "" - # secret: - # secretName: "" - volumeMounts: [] - # - mountPath: /etc/config/ - # name: volume[*].name - # readOnly: true - - podAnnotations: {} - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#podsecuritycontext-v1-core - podSecurityContext: {} - # fsGroup: 2 - # fsGroupChangePolicy: Always | OnRootMismatch - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#securitycontext-v1-core - securityContext: {} - # allowPrivilegeEscalation: false - # capabilities: - # add: [] - # drop: [] - # privileged: false - # readOnlyRootFilesystem: true - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#nodeselector-v1-core - nodeSelector: {} - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#toleration-v1-core - tolerations: [] - # - effect: NoSchedule | PreferNoSchedule | NoExecute - # key: "" - # operator: Exists | Equal - # tolerationSeconds: 600 - # value: "" - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#affinity-v1-core - affinity: {} - - -############################################# -# all workers # -############################################# -workers: - worker-name: - paused: true - replicaCount: 1 - image: - registry: "" - repository: kilianpaquier/craft - pullPolicy: "" - # Overrides the image tag whose default is the chart appVersion. - tag: "" - env: - BINARY_NAME: worker-name - BINARY_PORT: 5000 - envFrom: [] - # - prefix: "" - # configMapRef: - # name: "" - # secretRef: - # name: "" - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#probe-v1-core - livenessProbe: false - # httpGet: - # httpHeaders: - # header-name: value - # path: /ping - # port: 3000 - # scheme: http - # initialDelaySeconds: 15 - # periodSeconds: 10 - # successThreshold: 1 - # failureThreshold: 3 - readinessProbe: false - # exec: - # command: ["ls", "-lart"] - # initialDelaySeconds: 15 - # periodSeconds: 10 - # successThreshold: 1 - # failureThreshold: 3 - startupProbe: false - # grpc: - # port: 3000 - # service: "" - # initialDelaySeconds: 15 - # periodSeconds: 10 - # successThreshold: 1 - # failureThreshold: 3 - resources: - limits: - cpu: 250m - memory: 256Mi - storage: 10Gi - requests: - cpu: 50m - memory: 128Mi - storage: 5Gi - autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 10 - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 80 - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: 80 - restartPolicy: Always - configMap: {} - # mountPath: /etc/config/ - # tpl_folders: # folders to be included in configmap with tpl - # - folder_name - # include_folders: # folders to be included in configmap without tpl - # - folder_name - # data: - # name: value - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#volume-v1-core - volumes: [] - # - name: "" - # configMap: - # name: configMapName - # - name: "" - # emptyDir: - # medium: "" - # sizeLimit: 1Gi - # - name: "" - # persistentVolumeClaim: - # claimName: "" - # readOnly: false - # - name: "" - # secret: - # secretName: "" - volumeMounts: [] - # - mountPath: /etc/config/ - # name: volume[*].name - # readOnly: true - - podAnnotations: {} - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#podsecuritycontext-v1-core - podSecurityContext: {} - # fsGroup: 2 - # fsGroupChangePolicy: Always | OnRootMismatch - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#securitycontext-v1-core - securityContext: {} - # allowPrivilegeEscalation: false - # capabilities: - # add: [] - # drop: [] - # privileged: false - # readOnlyRootFilesystem: true - # runAsGroup: 1001 - # runAsNonRoot: true - # runAsUser: 1001 - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#nodeselector-v1-core - nodeSelector: {} - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#toleration-v1-core - tolerations: [] - # - effect: NoSchedule | PreferNoSchedule | NoExecute - # key: "" - # operator: Exists | Equal - # tolerationSeconds: 600 - # value: "" - - # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#affinity-v1-core - affinity: {} - - -############################################# -# all dependencies # -############################################# \ No newline at end of file diff --git a/testdata/hugo/success_bot_github_dependabot/.github/dependabot.yml b/testdata/hugo/success_bot_github_dependabot/.github/dependabot.yml deleted file mode 100644 index 92bad2b0..00000000 --- a/testdata/hugo/success_bot_github_dependabot/.github/dependabot.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# 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/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - -version: 2 -updates: - - - package-ecosystem: github-actions - directory: / - schedule: - interval: daily - time: "12:00" - timezone: "Etc/UTC" - groups: - major/minor/patch: - update-types: - - major - - minor - - patch - commit-message: - include: scope - prefix: ci - reviewers: - - maintainer name \ No newline at end of file diff --git a/testdata/hugo/success_bot_github_dependabot/.github/release.yml b/testdata/hugo/success_bot_github_dependabot/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/hugo/success_bot_github_dependabot/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/hugo/success_bot_github_dependabot/.gitignore b/testdata/hugo/success_bot_github_dependabot/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/hugo/success_bot_github_dependabot/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/hugo/success_bot_github_dependabot/README.md b/testdata/hugo/success_bot_github_dependabot/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/hugo/success_bot_github_dependabot/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_bot_github_renovate/.github/release.yml b/testdata/hugo/success_bot_github_renovate/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/hugo/success_bot_github_renovate/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/hugo/success_bot_github_renovate/README.md b/testdata/hugo/success_bot_github_renovate/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/hugo/success_bot_github_renovate/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_bot_github_renovate/renovate.json5 b/testdata/hugo/success_bot_github_renovate/renovate.json5 deleted file mode 100644 index b5a60ee1..00000000 --- a/testdata/hugo/success_bot_github_renovate/renovate.json5 +++ /dev/null @@ -1,207 +0,0 @@ -// Code generated by craft; DO NOT EDIT. - -// https://docs.renovatebot.com/configuration-options/ - -{ - "extends": [ ":gitSignOff" ], - "enabled": true, - "branchPrefix": "renovate/", - "labels": [ "dependencies" ], - - "branchConcurrentLimit": 0, - "prConcurrentLimit": 0, - "prCreation": "immediate", - "prHourlyLimit": 0, - - "ignorePaths": [ - "**/bower_components/**", - "**/examples/**", - "**/fixtures/**", - "**/node_modules/**", - "**/test/**", - "**/testdata/**", - "**/tests/**", - ], - - "dependencyDashboard": false, - "osvVulnerabilityAlerts": false, // https://github.com/renovatebot/renovate/discussions/20542 - "forkProcessing": "disabled", - - "minimumReleaseAge": "7 days", - "fetchChangeLogs": "pr", - - "semanticCommits": "auto", - "semanticCommitType": "chore", - "semanticCommitScope": "deps", - - "separateMajorMinor": true, - "separateMinorPatch": false, - "separateMultipleMajor": true, - "separateMultipleMinor": false, - - "baseBranches": [ - "$default", - "/^v[0-9]+\.x/", - "/^v[0-9]+\.[0-9]+\.x/", - ], - - "reviewers": [ - "maintainer name", - ], - "bbUseDefaultReviewers": true, - "gitLabIgnoreApprovals": true, - - "assignAutomerge": true, - "automerge": "false", - "automergeStrategy": "fast-forward", - "automergeType": "pr", - "platformAutomerge": true, - - "rebaseLabel": "rebase", - "rebaseWhen": "behind-base-branch", - "recreateWhen": "auto", - "stopUpdatingLabel": "pause", - - "commitMessageLowerCase": "auto", - "configMigration": false, // removes comments and sets indent to 2 and add a lot of newlines (https://github.com/renovatebot/renovate/issues/16359) - "platformCommit": "auto", - - "goGetDirs": [ "./..." ], - "postUpdateOptions": [ - "gomodTidy", - "gomodUpdateImportPaths", - "helmUpdateSubChartArchives" - ], - "rangeStrategy": "bump", - "updateLockFiles": true, - "useBaseBranchConfig": "none", - - "lockFileMaintenance": { "automerge": true }, - "major": { "automerge": false }, - "minor": { "automerge": true }, - "patch": { "automerge": true }, - "pin": { "automerge": true }, - - "packageRules": [ - { - "addLabels": [ "non-major" ], - "groupName": "cd dependencies (non major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "cd dependencies (major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "ci dependencies (non major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "ci dependencies (major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "golang dependencies (non major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "golang dependencies (major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "js dependencies (non major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "js dependencies (major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "major" ] - }, - ], -} \ No newline at end of file diff --git a/testdata/hugo/success_options_github/.codecov.yml b/testdata/hugo/success_options_github/.codecov.yml deleted file mode 100644 index 01d8cb8f..00000000 --- a/testdata/hugo/success_options_github/.codecov.yml +++ /dev/null @@ -1,14 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -coverage: - precision: 2 - round: down - range: 85...100 - - status: - project: - default: - threshold: 2.5% - patch: - default: - threshold: 2.5% \ No newline at end of file diff --git a/testdata/hugo/success_options_github/.github/labeler.yml b/testdata/hugo/success_options_github/.github/labeler.yml deleted file mode 100644 index 80a075d4..00000000 --- a/testdata/hugo/success_options_github/.github/labeler.yml +++ /dev/null @@ -1,92 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://github.com/marketplace/actions/release-drafter#autolabeler - -autolabeler: - - label: enhancement - title: - - /feat\/.+/ - - /refactor\/.+/ - branch: - - /dev\/.+/ - - - label: breaking - body: - - /.*BREAKING.*/ - - - label: bug - title: - - /fix\/.+/ - - /perf\/.+/ - - /revert\/.+/ - branch: - - /(hot)?fix\/.+/ - - - label: documentation - title: - - /doc(s)?\/.+/ - branch: - - /doc(s)?\/.+/ - files: - - "**/*.md" - - "**/doc.go" - - "**/docs/**" - - - label: chore - title: - - /chore\/.+/ - - - label: test - title: - - /test\/.+/ - branch: - - /test\/.+/ - files: - - "**/*_test.go" - - "**/*.spec.js" - - "**/*.spec.ts" - - "**/*.test.js" - - "**/*.test.ts" - - "**/test/**" - - "**/testdata/**" - - "**/tests/**" - - - label: github_actions - files: - - "action.yml" - - "**/.github/actions/**" - - "**/.github/workflows/**" - - - label: go - files: - - "**/*.go" - - - label: javascript - files: - - "**/*.js" - - "**/*.ts" - - - label: python - files: - - "**/*.py" - - - label: rust - files: - - "**/*.rs" - - - label: shell - files: - - "**/*.sh" - - "**/*.zsh" - - "**/*.bash" - - - label: dependencies - title: - - /.*\(deps\).*/ - # files: - # - "**/go.mod" - # - "**/go.sum" - # - "**/package.json" - -template: | - $CHANGES \ No newline at end of file diff --git a/testdata/hugo/success_options_github/.github/release.yml b/testdata/hugo/success_options_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/hugo/success_options_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/hugo/success_options_github/.github/workflows/codeql.yml b/testdata/hugo/success_options_github/.github/workflows/codeql.yml deleted file mode 100644 index 6a8c85d1..00000000 --- a/testdata/hugo/success_options_github/.github/workflows/codeql.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: CodeQL -run-name: CodeQL - -on: - push: - branches: - - alpha - - beta - - dev - - develop - - development - - main - - master - - next - - staging - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - -jobs: - codeql: - name: CodeQL - runs-on: ubuntu-latest - permissions: - security-events: write - strategy: - fail-fast: false - matrix: - language: - - go - steps: - - uses: actions/checkout@v4 - - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - - uses: github/codeql-action/autobuild@v3 - - uses: github/codeql-action/analyze@v3 - with: - category: /language:${{ matrix.language }} \ No newline at end of file diff --git a/testdata/hugo/success_options_github/.github/workflows/hugo.yml b/testdata/hugo/success_options_github/.github/workflows/hugo.yml deleted file mode 100644 index 747134be..00000000 --- a/testdata/hugo/success_options_github/.github/workflows/hugo.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Hugo -run-name: Hugo - -on: - workflow_call: - -jobs: - - hugo-build: - name: Hugo Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true # fetch Hugo themes (true OR recursive) - fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod - - uses: actions/cache@v4 - with: - path: /home/runner/.cache/hugo_cache - key: hugo-${{ hashFiles('**/go.sum') }} - restore-keys: | - hugo- - # https://github.com/marketplace/actions/hugo-setup - - uses: peaceiris/actions-hugo@v3 - with: - hugo-version: latest - extended: true - - run: hugo --gc --minify --destination dist - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist - retention-days: 1 \ No newline at end of file diff --git a/testdata/hugo/success_options_github/.github/workflows/labeler.yml b/testdata/hugo/success_options_github/.github/workflows/labeler.yml deleted file mode 100644 index a729aada..00000000 --- a/testdata/hugo/success_options_github/.github/workflows/labeler.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Labeler -run-name: Labeler - -on: - pull_request: # autolabeler on project pull requests - types: - - opened - - reopened - - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize - -jobs: - - labeler: - name: Labeler - runs-on: ubuntu-latest - permissions: - contents: read # enfore rights to specify no release, even draft, is created - pull-requests: write - steps: - # https://github.com/marketplace/actions/release-drafter - - id: drafter - uses: release-drafter/release-drafter@v6 - with: - commitish: ${{ github.base_ref }} - config-name: labeler.yml - latest: false - name: v$RESOLVED_VERSION - prerelease-identifier: labeler - prerelease: true - publish: false - tag: v$RESOLVED_VERSION - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/testdata/hugo/success_options_github/.gitignore b/testdata/hugo/success_options_github/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/hugo/success_options_github/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/hugo/success_options_github/README.md b/testdata/hugo/success_options_github/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/hugo/success_options_github/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_options_gitlab/.gitignore b/testdata/hugo/success_options_gitlab/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/hugo/success_options_gitlab/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/hugo/success_options_gitlab/.gitlab-ci.yml b/testdata/hugo/success_options_gitlab/.gitlab-ci.yml deleted file mode 100644 index 71988199..00000000 --- a/testdata/hugo/success_options_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -# SONAR_TOKEN: SonarQube authentication token (depends on your authentication method) -# SONAR_LOGIN: SonarQube login (depends on your authentication method) -# SONAR_PASSWORD: SonarQube password (depends on your authentication method) - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/hugo/success_options_gitlab/.gitlab/semrel-plugins.txt b/testdata/hugo/success_options_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index 9da763d1..00000000 --- a/testdata/hugo/success_options_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,7 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/hugo/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/hugo/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 62877776..00000000 --- a/testdata/hugo/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,83 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # SonarQube template - - project: "to-be-continuous/sonar" - ref: "4" - file: "templates/gitlab-ci-sonar.yml" - -variables: - - SONAR_HOST_URL: "https://sonarcloud.io" - SONAR_BASE_ARGS: | - -Dsonar.properties=sonar.properties - -Dsonar.links.homepage=${CI_PROJECT_URL} - -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines - -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues - SONAR_QUALITY_GATE_ENABLED: "true" - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -hugo-build: - image: registry.gitlab.com/pages/hugo/hugo_extended:latest - stage: build - variables: - DIST_FOLDER: dist - before_script: - - apk add go - script: - - hugo --gc --minify --destination "$DIST_FOLDER" - artifacts: - name: $ENV - paths: - - $DIST_FOLDER - expire_in: 1 day \ No newline at end of file diff --git a/testdata/hugo/success_options_gitlab/README.md b/testdata/hugo/success_options_gitlab/README.md deleted file mode 100644 index fb03b9da..00000000 --- a/testdata/hugo/success_options_gitlab/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/.gitignore b/testdata/hugo/success_release_gitlab/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/hugo/success_release_gitlab/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/.gitlab-ci.yml b/testdata/hugo/success_release_gitlab/.gitlab-ci.yml deleted file mode 100644 index 37bcd914..00000000 --- a/testdata/hugo/success_release_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/.gitlab/semrel-plugins.txt b/testdata/hugo/success_release_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index 9da763d1..00000000 --- a/testdata/hugo/success_release_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,7 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/hugo/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 07513de7..00000000 --- a/testdata/hugo/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,70 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - -variables: - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "false" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -hugo-build: - image: registry.gitlab.com/pages/hugo/hugo_extended:latest - stage: build - variables: - DIST_FOLDER: dist - before_script: - - apk add go - script: - - hugo --gc --minify --destination "$DIST_FOLDER" - artifacts: - name: $ENV - paths: - - $DIST_FOLDER - expire_in: 1 day \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/.releaserc.yml b/testdata/hugo/success_release_gitlab/.releaserc.yml deleted file mode 100644 index eb605248..00000000 --- a/testdata/hugo/success_release_gitlab/.releaserc.yml +++ /dev/null @@ -1,89 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://semantic-release.gitbook.io/semantic-release/usage/configuration - -branches: - - (master|main) - - v+([0-9])?(.{+([0-9]),x}).x - - name: next - prerelease: true - - name: beta - prerelease: true - - name: alpha - prerelease: true - - name: staging - prerelease: beta - - name: (dev|develop|development) - prerelease: alpha - -tagFormat: v${version} - -plugins: - - - "@semantic-release/commit-analyzer" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - releaseRules: - - { breaking: true, release: major } - - { revert: true, release: patch } - - { type: feat, release: minor } - - { type: fix, release: patch } - - { type: revert, release: patch } - - { type: perf, release: patch } - - { type: docs, release: patch } - - { type: chore, release: patch } - - { type: refactor, release: minor } - - - { scope: release, release: false } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - - "@semantic-release/release-notes-generator" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - "@semantic-release/changelog" - - - "@semantic-release/git" - - assets: - - CHANGELOG.md - message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - - - "@semantic-release/gitlab" - - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} - failCommentCondition: <% return false; %> - successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 - successCommentCondition: <% return true; %> - assets: - - label: CHANGELOG.md - path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/Makefile b/testdata/hugo/success_release_gitlab/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/hugo/success_release_gitlab/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/README.md b/testdata/hugo/success_release_gitlab/README.md deleted file mode 100644 index fb03b9da..00000000 --- a/testdata/hugo/success_release_gitlab/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/scripts/build.mk b/testdata/hugo/success_release_gitlab/scripts/build.mk deleted file mode 100644 index 8f2a528c..00000000 --- a/testdata/hugo/success_release_gitlab/scripts/build.mk +++ /dev/null @@ -1,13 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: build -build: - @hugo --gc --minify --destination dist - -.PHONY: serve -serve: - @hugo server --disableFastRender - -.PHONY: production -production: build - @python3 -m http.server --directory dist \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/scripts/craft.mk b/testdata/hugo/success_release_gitlab/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/hugo/success_release_gitlab/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/hugo/success_release_gitlab/scripts/install.mk b/testdata/hugo/success_release_gitlab/scripts/install.mk deleted file mode 100644 index 39aa2114..00000000 --- a/testdata/hugo/success_release_gitlab/scripts/install.mk +++ /dev/null @@ -1,18 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -define install_hugo -current_version=$(hugo version || echo "hugo v0.0.0") -new_version=$(curl -fsSL "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.tag_name') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest hugo version ${new_version} already installed" - exit 0 -fi - -echo "installing latest hugo version ${new_version}" -rm -rf "${HOME}/.local/hugo" && mkdir -p "${HOME}/.local/hugo" -curl -fsSL "https://github.com/gohugoio/hugo/releases/download/${new_version}/hugo_extended_${new_version#v*}_linux-amd64.tar.gz" | (cd "${HOME}/.local/hugo" && tar -xz) -chmod +x "${HOME}/.local/hugo/hugo" && ln -sf "${HOME}/.local/hugo/hugo" "${HOME}/.local/bin/hugo" -endef -.PHONY: install-hugo -install-hugo: ; @$(value install_hugo) -.ONESHELL: \ No newline at end of file diff --git a/testdata/hugo/success_releases_github/.github/actions/version/action.yml b/testdata/hugo/success_releases_github/.github/actions/version/action.yml deleted file mode 100644 index 4670c18e..00000000 --- a/testdata/hugo/success_releases_github/.github/actions/version/action.yml +++ /dev/null @@ -1,95 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/testdata/hugo/success_releases_github/.github/release.yml b/testdata/hugo/success_releases_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/hugo/success_releases_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/hugo/success_releases_github/.github/workflows/hugo.yml b/testdata/hugo/success_releases_github/.github/workflows/hugo.yml deleted file mode 100644 index 747134be..00000000 --- a/testdata/hugo/success_releases_github/.github/workflows/hugo.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Hugo -run-name: Hugo - -on: - workflow_call: - -jobs: - - hugo-build: - name: Hugo Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true # fetch Hugo themes (true OR recursive) - fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod - - uses: actions/cache@v4 - with: - path: /home/runner/.cache/hugo_cache - key: hugo-${{ hashFiles('**/go.sum') }} - restore-keys: | - hugo- - # https://github.com/marketplace/actions/hugo-setup - - uses: peaceiris/actions-hugo@v3 - with: - hugo-version: latest - extended: true - - run: hugo --gc --minify --destination dist - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist - retention-days: 1 \ No newline at end of file diff --git a/testdata/hugo/success_releases_github/.github/workflows/release.yml b/testdata/hugo/success_releases_github/.github/workflows/release.yml deleted file mode 100644 index 2eda5eb2..00000000 --- a/testdata/hugo/success_releases_github/.github/workflows/release.yml +++ /dev/null @@ -1,73 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - id: app_token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.RELEASE_APP_ID }} - private-key: ${{ secrets.PRIVATE_KEY }} - - uses: actions/checkout@v4 - with: - token: ${{ steps.app_token.outputs.token }} - persist-credentials: false - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ steps.app_token.outputs.token }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - release: - name: Release - runs-on: ubuntu-latest - environment: release - needs: - - version - steps: - - id: app_token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.RELEASE_APP_ID }} - private-key: ${{ secrets.PRIVATE_KEY }} - - uses: actions/checkout@v4 - with: - token: ${{ steps.app_token.outputs.token }} - persist-credentials: false - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ steps.app_token.outputs.token }} \ No newline at end of file diff --git a/testdata/hugo/success_releases_github/.gitignore b/testdata/hugo/success_releases_github/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/hugo/success_releases_github/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/hugo/success_releases_github/.releaserc.yml b/testdata/hugo/success_releases_github/.releaserc.yml deleted file mode 100644 index 0d4b7220..00000000 --- a/testdata/hugo/success_releases_github/.releaserc.yml +++ /dev/null @@ -1,90 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://semantic-release.gitbook.io/semantic-release/usage/configuration - -branches: - - (master|main) - - v+([0-9])?(.{+([0-9]),x}).x - - name: next - prerelease: true - - name: beta - prerelease: true - - name: alpha - prerelease: true - - name: staging - prerelease: beta - - name: (dev|develop|development) - prerelease: alpha - -tagFormat: v${version} - -plugins: - - - "@semantic-release/commit-analyzer" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - releaseRules: - - { breaking: true, release: major } - - { revert: true, release: patch } - - { type: feat, release: minor } - - { type: fix, release: patch } - - { type: revert, release: patch } - - { type: perf, release: patch } - - { type: docs, release: patch } - - { type: chore, release: patch } - - { type: refactor, release: minor } - - - { scope: release, release: false } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - - "@semantic-release/release-notes-generator" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - "@semantic-release/changelog" - - - "@semantic-release/git" - - assets: - - CHANGELOG.md - message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - - - "@semantic-release/github" - - draftRelease: false - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} - failCommentCondition: <% return false; %> - successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 - successCommentCondition: <% return true; %> - assets: - - label: CHANGELOG.md - path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file diff --git a/testdata/hugo/success_releases_github/README.md b/testdata/hugo/success_releases_github/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/hugo/success_releases_github/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/.github/release.yml b/testdata/hugo/success_static_netlify_auto_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/.github/workflows/hugo.yml b/testdata/hugo/success_static_netlify_auto_github/.github/workflows/hugo.yml deleted file mode 100644 index 747134be..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/.github/workflows/hugo.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Hugo -run-name: Hugo - -on: - workflow_call: - -jobs: - - hugo-build: - name: Hugo Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true # fetch Hugo themes (true OR recursive) - fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod - - uses: actions/cache@v4 - with: - path: /home/runner/.cache/hugo_cache - key: hugo-${{ hashFiles('**/go.sum') }} - restore-keys: | - hugo- - # https://github.com/marketplace/actions/hugo-setup - - uses: peaceiris/actions-hugo@v3 - with: - hugo-version: latest - extended: true - - run: hugo --gc --minify --destination dist - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist - retention-days: 1 \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/.github/workflows/netlify.yml b/testdata/hugo/success_static_netlify_auto_github/.github/workflows/netlify.yml deleted file mode 100644 index e7c80067..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/.github/workflows/netlify.yml +++ /dev/null @@ -1,64 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Netlify -run-name: Netlify - -on: - workflow_call: - workflow_dispatch: - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - -jobs: - - hugo: - name: Hugo - uses: ./.github/workflows/hugo.yml - - netlify: - name: Netlify - runs-on: ubuntu-latest - environment: - name: netlify - url: ${{ steps.netlify.outputs.deploy-url }} - permissions: - deployments: write - pull-requests: write - needs: - - hugo - steps: - - uses: actions/checkout@v4 - - id: branch_sha - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - uses: actions/download-artifact@v4 - with: - name: build - path: dist - - id: netlify - uses: nwtgck/actions-netlify@v3 - with: - alias: ${{ steps.branch_sha.outputs.branch_sha }} - deploy-message: ${{ github.ref_name }} - enable-commit-comment: false - enable-commit-status: false - github-deployment-environment: netlify - github-token: ${{ secrets.GITHUB_TOKEN }} - netlify-config-path: netlify.toml - production-branch: ${{ github.event.repository.default_branch }} - publish-dir: dist - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/.gitignore b/testdata/hugo/success_static_netlify_auto_github/.gitignore deleted file mode 100644 index 30da5bc9..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock - -# Local Netlify folder -.netlify \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/Makefile b/testdata/hugo/success_static_netlify_auto_github/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/README.md b/testdata/hugo/success_static_netlify_auto_github/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/scripts/build.mk b/testdata/hugo/success_static_netlify_auto_github/scripts/build.mk deleted file mode 100644 index aaeebd6f..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/scripts/build.mk +++ /dev/null @@ -1,17 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: build -build: - @hugo --gc --minify --destination dist - -.PHONY: serve -serve: - @hugo server --disableFastRender - -.PHONY: production -production: - @netlify dev -c "make serve" \ - --target-port 1313 --port 8888 - --dir dist - --framework hugo - --context production \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/scripts/craft.mk b/testdata/hugo/success_static_netlify_auto_github/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_auto_github/scripts/install.mk b/testdata/hugo/success_static_netlify_auto_github/scripts/install.mk deleted file mode 100644 index 3bc0e106..00000000 --- a/testdata/hugo/success_static_netlify_auto_github/scripts/install.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -define install_hugo -current_version=$(hugo version || echo "hugo v0.0.0") -new_version=$(curl -fsSL "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.tag_name') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest hugo version ${new_version} already installed" - exit 0 -fi - -echo "installing latest hugo version ${new_version}" -rm -rf "${HOME}/.local/hugo" && mkdir -p "${HOME}/.local/hugo" -curl -fsSL "https://github.com/gohugoio/hugo/releases/download/${new_version}/hugo_extended_${new_version#v*}_linux-amd64.tar.gz" | (cd "${HOME}/.local/hugo" && tar -xz) -chmod +x "${HOME}/.local/hugo/hugo" && ln -sf "${HOME}/.local/hugo/hugo" "${HOME}/.local/bin/hugo" -endef -.PHONY: install-hugo -install-hugo: ; @$(value install_hugo) -.ONESHELL: - -define install_netlify -if which netlify >/dev/null; then - echo "netlify already installed" - exit 0 -fi - -echo "installing netlify" -for bin in "bun" "pnpm" "npm"; do - if which ${bin}; then - ${bin} i -g netlify-cli - exit $? - fi -done -endef -.PHONY: install-netlify -install-netlify: ; @$(value install_netlify) -.ONESHELL: \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/.github/release.yml b/testdata/hugo/success_static_netlify_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/hugo/success_static_netlify_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/.github/workflows/hugo.yml b/testdata/hugo/success_static_netlify_github/.github/workflows/hugo.yml deleted file mode 100644 index 747134be..00000000 --- a/testdata/hugo/success_static_netlify_github/.github/workflows/hugo.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Hugo -run-name: Hugo - -on: - workflow_call: - -jobs: - - hugo-build: - name: Hugo Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true # fetch Hugo themes (true OR recursive) - fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod - - uses: actions/cache@v4 - with: - path: /home/runner/.cache/hugo_cache - key: hugo-${{ hashFiles('**/go.sum') }} - restore-keys: | - hugo- - # https://github.com/marketplace/actions/hugo-setup - - uses: peaceiris/actions-hugo@v3 - with: - hugo-version: latest - extended: true - - run: hugo --gc --minify --destination dist - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist - retention-days: 1 \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/.github/workflows/netlify.yml b/testdata/hugo/success_static_netlify_github/.github/workflows/netlify.yml deleted file mode 100644 index 2fb1d9cc..00000000 --- a/testdata/hugo/success_static_netlify_github/.github/workflows/netlify.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Netlify -run-name: Netlify - -on: - workflow_call: - workflow_dispatch: - -jobs: - - hugo: - name: Hugo - uses: ./.github/workflows/hugo.yml - - netlify: - name: Netlify - runs-on: ubuntu-latest - environment: - name: netlify - url: ${{ steps.netlify.outputs.deploy-url }} - permissions: - deployments: write - pull-requests: write - needs: - - hugo - steps: - - uses: actions/checkout@v4 - - id: branch_sha - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - uses: actions/download-artifact@v4 - with: - name: build - path: dist - - id: netlify - uses: nwtgck/actions-netlify@v3 - with: - alias: ${{ steps.branch_sha.outputs.branch_sha }} - deploy-message: ${{ github.ref_name }} - enable-commit-comment: false - enable-commit-status: false - github-deployment-environment: netlify - github-token: ${{ secrets.GITHUB_TOKEN }} - netlify-config-path: netlify.toml - production-branch: ${{ github.event.repository.default_branch }} - publish-dir: dist - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/.gitignore b/testdata/hugo/success_static_netlify_github/.gitignore deleted file mode 100644 index 30da5bc9..00000000 --- a/testdata/hugo/success_static_netlify_github/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock - -# Local Netlify folder -.netlify \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/Makefile b/testdata/hugo/success_static_netlify_github/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/hugo/success_static_netlify_github/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/README.md b/testdata/hugo/success_static_netlify_github/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/hugo/success_static_netlify_github/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/scripts/build.mk b/testdata/hugo/success_static_netlify_github/scripts/build.mk deleted file mode 100644 index aaeebd6f..00000000 --- a/testdata/hugo/success_static_netlify_github/scripts/build.mk +++ /dev/null @@ -1,17 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: build -build: - @hugo --gc --minify --destination dist - -.PHONY: serve -serve: - @hugo server --disableFastRender - -.PHONY: production -production: - @netlify dev -c "make serve" \ - --target-port 1313 --port 8888 - --dir dist - --framework hugo - --context production \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/scripts/craft.mk b/testdata/hugo/success_static_netlify_github/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/hugo/success_static_netlify_github/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_github/scripts/install.mk b/testdata/hugo/success_static_netlify_github/scripts/install.mk deleted file mode 100644 index 3bc0e106..00000000 --- a/testdata/hugo/success_static_netlify_github/scripts/install.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -define install_hugo -current_version=$(hugo version || echo "hugo v0.0.0") -new_version=$(curl -fsSL "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.tag_name') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest hugo version ${new_version} already installed" - exit 0 -fi - -echo "installing latest hugo version ${new_version}" -rm -rf "${HOME}/.local/hugo" && mkdir -p "${HOME}/.local/hugo" -curl -fsSL "https://github.com/gohugoio/hugo/releases/download/${new_version}/hugo_extended_${new_version#v*}_linux-amd64.tar.gz" | (cd "${HOME}/.local/hugo" && tar -xz) -chmod +x "${HOME}/.local/hugo/hugo" && ln -sf "${HOME}/.local/hugo/hugo" "${HOME}/.local/bin/hugo" -endef -.PHONY: install-hugo -install-hugo: ; @$(value install_hugo) -.ONESHELL: - -define install_netlify -if which netlify >/dev/null; then - echo "netlify already installed" - exit 0 -fi - -echo "installing netlify" -for bin in "bun" "pnpm" "npm"; do - if which ${bin}; then - ${bin} i -g netlify-cli - exit $? - fi -done -endef -.PHONY: install-netlify -install-netlify: ; @$(value install_netlify) -.ONESHELL: \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/.gitignore b/testdata/hugo/success_static_netlify_gitlab/.gitignore deleted file mode 100644 index 30da5bc9..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock - -# Local Netlify folder -.netlify \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/.gitlab-ci.yml b/testdata/hugo/success_static_netlify_gitlab/.gitlab-ci.yml deleted file mode 100644 index 802b11f5..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -# NETLIFY_SITE_ID: The netlify site ID where builds will be published (should be retrieved if the project name is the same here https://app.netlify.com/sites/craft/configuration/general) -# NETLIFY_AUTH_TOKEN: The netlify authentication token (it's a personal token) to use for deployments (once connected, can be retrieved here https://app.netlify.com/user/applications#content) - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/.gitlab/semrel-plugins.txt b/testdata/hugo/success_static_netlify_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index 9da763d1..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,7 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/hugo/success_static_netlify_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 0a08ada1..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,93 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - -variables: - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -hugo-build: - image: registry.gitlab.com/pages/hugo/hugo_extended:latest - stage: build - variables: - DIST_FOLDER: dist - before_script: - - apk add go - script: - - hugo --gc --minify --destination "$DIST_FOLDER" - artifacts: - name: $ENV - paths: - - $DIST_FOLDER - expire_in: 1 day - -netlify: - stage: deploy - image: node:lts-alpine - environment: - name: $ENV - action: start - variables: - DIST_FOLDER: dist - rules: - - if: $CI_COMMIT_REF_PROTECTED == 'true' - variables: - ARGS: "--prod" - ENV: production - when: manual - - variables: - ARGS: "--alias $BRANCH_SHA" # sha is coming from version.yml file with export from semantic-release-info job - ENV: $CI_COMMIT_REF_NAME - when: manual - before_script: - - npm install -g netlify-cli - script: - - netlify deploy --site "$NETLIFY_SITE_ID" --auth "$NETLIFY_AUTH_TOKEN" --dir "$DIST_FOLDER" "$ARGS" \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/Makefile b/testdata/hugo/success_static_netlify_gitlab/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/README.md b/testdata/hugo/success_static_netlify_gitlab/README.md deleted file mode 100644 index fb03b9da..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/scripts/build.mk b/testdata/hugo/success_static_netlify_gitlab/scripts/build.mk deleted file mode 100644 index aaeebd6f..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/scripts/build.mk +++ /dev/null @@ -1,17 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: build -build: - @hugo --gc --minify --destination dist - -.PHONY: serve -serve: - @hugo server --disableFastRender - -.PHONY: production -production: - @netlify dev -c "make serve" \ - --target-port 1313 --port 8888 - --dir dist - --framework hugo - --context production \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/scripts/craft.mk b/testdata/hugo/success_static_netlify_gitlab/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/hugo/success_static_netlify_gitlab/scripts/install.mk b/testdata/hugo/success_static_netlify_gitlab/scripts/install.mk deleted file mode 100644 index 3bc0e106..00000000 --- a/testdata/hugo/success_static_netlify_gitlab/scripts/install.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -define install_hugo -current_version=$(hugo version || echo "hugo v0.0.0") -new_version=$(curl -fsSL "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.tag_name') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest hugo version ${new_version} already installed" - exit 0 -fi - -echo "installing latest hugo version ${new_version}" -rm -rf "${HOME}/.local/hugo" && mkdir -p "${HOME}/.local/hugo" -curl -fsSL "https://github.com/gohugoio/hugo/releases/download/${new_version}/hugo_extended_${new_version#v*}_linux-amd64.tar.gz" | (cd "${HOME}/.local/hugo" && tar -xz) -chmod +x "${HOME}/.local/hugo/hugo" && ln -sf "${HOME}/.local/hugo/hugo" "${HOME}/.local/bin/hugo" -endef -.PHONY: install-hugo -install-hugo: ; @$(value install_hugo) -.ONESHELL: - -define install_netlify -if which netlify >/dev/null; then - echo "netlify already installed" - exit 0 -fi - -echo "installing netlify" -for bin in "bun" "pnpm" "npm"; do - if which ${bin}; then - ${bin} i -g netlify-cli - exit $? - fi -done -endef -.PHONY: install-netlify -install-netlify: ; @$(value install_netlify) -.ONESHELL: \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/.github/release.yml b/testdata/hugo/success_static_pages_auto_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/hugo/success_static_pages_auto_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/.github/workflows/hugo.yml b/testdata/hugo/success_static_pages_auto_github/.github/workflows/hugo.yml deleted file mode 100644 index 318e763f..00000000 --- a/testdata/hugo/success_static_pages_auto_github/.github/workflows/hugo.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Hugo -run-name: Hugo - -on: - workflow_call: - -jobs: - - hugo-build: - name: Hugo Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true # fetch Hugo themes (true OR recursive) - fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod - - uses: actions/cache@v4 - with: - path: /home/runner/.cache/hugo_cache - key: hugo-${{ hashFiles('**/go.sum') }} - restore-keys: | - hugo- - # https://github.com/marketplace/actions/hugo-setup - - uses: peaceiris/actions-hugo@v3 - with: - hugo-version: latest - extended: true - - run: hugo --gc --minify --destination dist - - uses: actions/upload-pages-artifact@v3 - with: - name: github-pages - path: dist - retention-days: 1 - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist - retention-days: 1 \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/.github/workflows/pages.yml b/testdata/hugo/success_static_pages_auto_github/.github/workflows/pages.yml deleted file mode 100644 index 6001a882..00000000 --- a/testdata/hugo/success_static_pages_auto_github/.github/workflows/pages.yml +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Pages -run-name: Pages - -on: - workflow_call: - workflow_dispatch: - push: - branches: - - main - - master - - v[0-9]+.x - - v[0-9]+.[0-9]+.x - -jobs: - - hugo: - name: Hugo - uses: ./.github/workflows/hugo.yml - - pages: - name: Pages - runs-on: ubuntu-latest - needs: - - hugo - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - permissions: - pages: write - id-token: write - steps: - - id: deployment - uses: actions/deploy-pages@v4 - with: - artifact_name: github-pages - preview: ${{ github.ref_name != github.event.repository.default_branch }} \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/.gitignore b/testdata/hugo/success_static_pages_auto_github/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/hugo/success_static_pages_auto_github/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/Makefile b/testdata/hugo/success_static_pages_auto_github/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/hugo/success_static_pages_auto_github/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/README.md b/testdata/hugo/success_static_pages_auto_github/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/hugo/success_static_pages_auto_github/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/scripts/build.mk b/testdata/hugo/success_static_pages_auto_github/scripts/build.mk deleted file mode 100644 index 8f2a528c..00000000 --- a/testdata/hugo/success_static_pages_auto_github/scripts/build.mk +++ /dev/null @@ -1,13 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: build -build: - @hugo --gc --minify --destination dist - -.PHONY: serve -serve: - @hugo server --disableFastRender - -.PHONY: production -production: build - @python3 -m http.server --directory dist \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/scripts/craft.mk b/testdata/hugo/success_static_pages_auto_github/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/hugo/success_static_pages_auto_github/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_auto_github/scripts/install.mk b/testdata/hugo/success_static_pages_auto_github/scripts/install.mk deleted file mode 100644 index 39aa2114..00000000 --- a/testdata/hugo/success_static_pages_auto_github/scripts/install.mk +++ /dev/null @@ -1,18 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -define install_hugo -current_version=$(hugo version || echo "hugo v0.0.0") -new_version=$(curl -fsSL "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.tag_name') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest hugo version ${new_version} already installed" - exit 0 -fi - -echo "installing latest hugo version ${new_version}" -rm -rf "${HOME}/.local/hugo" && mkdir -p "${HOME}/.local/hugo" -curl -fsSL "https://github.com/gohugoio/hugo/releases/download/${new_version}/hugo_extended_${new_version#v*}_linux-amd64.tar.gz" | (cd "${HOME}/.local/hugo" && tar -xz) -chmod +x "${HOME}/.local/hugo/hugo" && ln -sf "${HOME}/.local/hugo/hugo" "${HOME}/.local/bin/hugo" -endef -.PHONY: install-hugo -install-hugo: ; @$(value install_hugo) -.ONESHELL: \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/.github/release.yml b/testdata/hugo/success_static_pages_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/hugo/success_static_pages_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/.github/workflows/hugo.yml b/testdata/hugo/success_static_pages_github/.github/workflows/hugo.yml deleted file mode 100644 index 318e763f..00000000 --- a/testdata/hugo/success_static_pages_github/.github/workflows/hugo.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Hugo -run-name: Hugo - -on: - workflow_call: - -jobs: - - hugo-build: - name: Hugo Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true # fetch Hugo themes (true OR recursive) - fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod - - uses: actions/cache@v4 - with: - path: /home/runner/.cache/hugo_cache - key: hugo-${{ hashFiles('**/go.sum') }} - restore-keys: | - hugo- - # https://github.com/marketplace/actions/hugo-setup - - uses: peaceiris/actions-hugo@v3 - with: - hugo-version: latest - extended: true - - run: hugo --gc --minify --destination dist - - uses: actions/upload-pages-artifact@v3 - with: - name: github-pages - path: dist - retention-days: 1 - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist - retention-days: 1 \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/.github/workflows/pages.yml b/testdata/hugo/success_static_pages_github/.github/workflows/pages.yml deleted file mode 100644 index 19fce363..00000000 --- a/testdata/hugo/success_static_pages_github/.github/workflows/pages.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Pages -run-name: Pages - -on: - workflow_call: - workflow_dispatch: - -jobs: - - hugo: - name: Hugo - uses: ./.github/workflows/hugo.yml - - pages: - name: Pages - runs-on: ubuntu-latest - needs: - - hugo - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - permissions: - pages: write - id-token: write - steps: - - id: deployment - uses: actions/deploy-pages@v4 - with: - artifact_name: github-pages - preview: ${{ github.ref_name != github.event.repository.default_branch }} \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/.gitignore b/testdata/hugo/success_static_pages_github/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/hugo/success_static_pages_github/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/Makefile b/testdata/hugo/success_static_pages_github/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/hugo/success_static_pages_github/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/README.md b/testdata/hugo/success_static_pages_github/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/hugo/success_static_pages_github/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/scripts/build.mk b/testdata/hugo/success_static_pages_github/scripts/build.mk deleted file mode 100644 index 8f2a528c..00000000 --- a/testdata/hugo/success_static_pages_github/scripts/build.mk +++ /dev/null @@ -1,13 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: build -build: - @hugo --gc --minify --destination dist - -.PHONY: serve -serve: - @hugo server --disableFastRender - -.PHONY: production -production: build - @python3 -m http.server --directory dist \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/scripts/craft.mk b/testdata/hugo/success_static_pages_github/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/hugo/success_static_pages_github/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_github/scripts/install.mk b/testdata/hugo/success_static_pages_github/scripts/install.mk deleted file mode 100644 index 39aa2114..00000000 --- a/testdata/hugo/success_static_pages_github/scripts/install.mk +++ /dev/null @@ -1,18 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -define install_hugo -current_version=$(hugo version || echo "hugo v0.0.0") -new_version=$(curl -fsSL "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.tag_name') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest hugo version ${new_version} already installed" - exit 0 -fi - -echo "installing latest hugo version ${new_version}" -rm -rf "${HOME}/.local/hugo" && mkdir -p "${HOME}/.local/hugo" -curl -fsSL "https://github.com/gohugoio/hugo/releases/download/${new_version}/hugo_extended_${new_version#v*}_linux-amd64.tar.gz" | (cd "${HOME}/.local/hugo" && tar -xz) -chmod +x "${HOME}/.local/hugo/hugo" && ln -sf "${HOME}/.local/hugo/hugo" "${HOME}/.local/bin/hugo" -endef -.PHONY: install-hugo -install-hugo: ; @$(value install_hugo) -.ONESHELL: \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/.gitignore b/testdata/hugo/success_static_pages_gitlab/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/hugo/success_static_pages_gitlab/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/.gitlab-ci.yml b/testdata/hugo/success_static_pages_gitlab/.gitlab-ci.yml deleted file mode 100644 index 37bcd914..00000000 --- a/testdata/hugo/success_static_pages_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/.gitlab/semrel-plugins.txt b/testdata/hugo/success_static_pages_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index 9da763d1..00000000 --- a/testdata/hugo/success_static_pages_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,7 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/hugo/success_static_pages_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 68c6225c..00000000 --- a/testdata/hugo/success_static_pages_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,94 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - -variables: - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -hugo-build: - image: registry.gitlab.com/pages/hugo/hugo_extended:latest - stage: build - variables: - DIST_FOLDER: dist - before_script: - - apk add go - script: - - hugo --gc --minify --destination "$DIST_FOLDER" - artifacts: - name: $ENV - paths: - - $DIST_FOLDER - expire_in: 1 day - -pages: - stage: deploy - environment: - name: $ENV - action: start - url: $CI_PAGES_URL - variables: - ENV: production - DIST_FOLDER: dist - rules: - - if: $CI_COMMIT_REF_PROTECTED == 'true' - when: manual - script: - - > - if [ "$DIST_FOLDER" != "public" ]; then - mkdir -p public - $DIST_FOLDER/* public - fi - artifacts: - name: $ENV - paths: - - public - expire_in: 1 day \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/Makefile b/testdata/hugo/success_static_pages_gitlab/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/hugo/success_static_pages_gitlab/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/README.md b/testdata/hugo/success_static_pages_gitlab/README.md deleted file mode 100644 index fb03b9da..00000000 --- a/testdata/hugo/success_static_pages_gitlab/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/scripts/build.mk b/testdata/hugo/success_static_pages_gitlab/scripts/build.mk deleted file mode 100644 index 8f2a528c..00000000 --- a/testdata/hugo/success_static_pages_gitlab/scripts/build.mk +++ /dev/null @@ -1,13 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: build -build: - @hugo --gc --minify --destination dist - -.PHONY: serve -serve: - @hugo server --disableFastRender - -.PHONY: production -production: build - @python3 -m http.server --directory dist \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/scripts/craft.mk b/testdata/hugo/success_static_pages_gitlab/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/hugo/success_static_pages_gitlab/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/hugo/success_static_pages_gitlab/scripts/install.mk b/testdata/hugo/success_static_pages_gitlab/scripts/install.mk deleted file mode 100644 index 39aa2114..00000000 --- a/testdata/hugo/success_static_pages_gitlab/scripts/install.mk +++ /dev/null @@ -1,18 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -define install_hugo -current_version=$(hugo version || echo "hugo v0.0.0") -new_version=$(curl -fsSL "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.tag_name') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest hugo version ${new_version} already installed" - exit 0 -fi - -echo "installing latest hugo version ${new_version}" -rm -rf "${HOME}/.local/hugo" && mkdir -p "${HOME}/.local/hugo" -curl -fsSL "https://github.com/gohugoio/hugo/releases/download/${new_version}/hugo_extended_${new_version#v*}_linux-amd64.tar.gz" | (cd "${HOME}/.local/hugo" && tar -xz) -chmod +x "${HOME}/.local/hugo/hugo" && ln -sf "${HOME}/.local/hugo/hugo" "${HOME}/.local/bin/hugo" -endef -.PHONY: install-hugo -install-hugo: ; @$(value install_hugo) -.ONESHELL: \ No newline at end of file diff --git a/testdata/nodejs/success_both_github_dependabot/.github/dependabot.yml b/testdata/nodejs/success_both_github_dependabot/.github/dependabot.yml deleted file mode 100644 index b9e01668..00000000 --- a/testdata/nodejs/success_both_github_dependabot/.github/dependabot.yml +++ /dev/null @@ -1,45 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# 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/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - -version: 2 -updates: - - - package-ecosystem: github-actions - directory: / - schedule: - interval: daily - time: "12:00" - timezone: "Etc/UTC" - groups: - major/minor/patch: - update-types: - - major - - minor - - patch - commit-message: - include: scope - prefix: ci - reviewers: - - maintainer name - - package-ecosystem: npm - directory: / - schedule: - interval: daily - time: "12:00" - timezone: "Etc/UTC" - groups: - minor: - update-types: - - minor - patch: - update-types: - - patch - commit-message: - include: scope - prefix: chore - reviewers: - - maintainer name \ No newline at end of file diff --git a/testdata/nodejs/success_both_github_dependabot/.github/release.yml b/testdata/nodejs/success_both_github_dependabot/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/nodejs/success_both_github_dependabot/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/nodejs/success_both_github_dependabot/.gitignore b/testdata/nodejs/success_both_github_dependabot/.gitignore deleted file mode 100644 index ef7f4401..00000000 --- a/testdata/nodejs/success_both_github_dependabot/.gitignore +++ /dev/null @@ -1,133 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file diff --git a/testdata/nodejs/success_both_github_dependabot/README.md b/testdata/nodejs/success_both_github_dependabot/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/nodejs/success_both_github_dependabot/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_both_github_renovate/.github/release.yml b/testdata/nodejs/success_both_github_renovate/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/nodejs/success_both_github_renovate/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/nodejs/success_both_github_renovate/README.md b/testdata/nodejs/success_both_github_renovate/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/nodejs/success_both_github_renovate/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_both_github_renovate/renovate.json5 b/testdata/nodejs/success_both_github_renovate/renovate.json5 deleted file mode 100644 index b5a60ee1..00000000 --- a/testdata/nodejs/success_both_github_renovate/renovate.json5 +++ /dev/null @@ -1,207 +0,0 @@ -// Code generated by craft; DO NOT EDIT. - -// https://docs.renovatebot.com/configuration-options/ - -{ - "extends": [ ":gitSignOff" ], - "enabled": true, - "branchPrefix": "renovate/", - "labels": [ "dependencies" ], - - "branchConcurrentLimit": 0, - "prConcurrentLimit": 0, - "prCreation": "immediate", - "prHourlyLimit": 0, - - "ignorePaths": [ - "**/bower_components/**", - "**/examples/**", - "**/fixtures/**", - "**/node_modules/**", - "**/test/**", - "**/testdata/**", - "**/tests/**", - ], - - "dependencyDashboard": false, - "osvVulnerabilityAlerts": false, // https://github.com/renovatebot/renovate/discussions/20542 - "forkProcessing": "disabled", - - "minimumReleaseAge": "7 days", - "fetchChangeLogs": "pr", - - "semanticCommits": "auto", - "semanticCommitType": "chore", - "semanticCommitScope": "deps", - - "separateMajorMinor": true, - "separateMinorPatch": false, - "separateMultipleMajor": true, - "separateMultipleMinor": false, - - "baseBranches": [ - "$default", - "/^v[0-9]+\.x/", - "/^v[0-9]+\.[0-9]+\.x/", - ], - - "reviewers": [ - "maintainer name", - ], - "bbUseDefaultReviewers": true, - "gitLabIgnoreApprovals": true, - - "assignAutomerge": true, - "automerge": "false", - "automergeStrategy": "fast-forward", - "automergeType": "pr", - "platformAutomerge": true, - - "rebaseLabel": "rebase", - "rebaseWhen": "behind-base-branch", - "recreateWhen": "auto", - "stopUpdatingLabel": "pause", - - "commitMessageLowerCase": "auto", - "configMigration": false, // removes comments and sets indent to 2 and add a lot of newlines (https://github.com/renovatebot/renovate/issues/16359) - "platformCommit": "auto", - - "goGetDirs": [ "./..." ], - "postUpdateOptions": [ - "gomodTidy", - "gomodUpdateImportPaths", - "helmUpdateSubChartArchives" - ], - "rangeStrategy": "bump", - "updateLockFiles": true, - "useBaseBranchConfig": "none", - - "lockFileMaintenance": { "automerge": true }, - "major": { "automerge": false }, - "minor": { "automerge": true }, - "patch": { "automerge": true }, - "pin": { "automerge": true }, - - "packageRules": [ - { - "addLabels": [ "non-major" ], - "groupName": "cd dependencies (non major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "cd dependencies (major)", - "matchCategories": [ "cd" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "ci dependencies (non major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "ci dependencies (major)", - "matchCategories": [ "ci" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "docker dependencies (non major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "docker dependencies (major)", - "matchCategories": [ "docker" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "golang dependencies (non major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "golang dependencies (major)", - "matchCategories": [ "golang" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "helm dependencies (non major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "helm dependencies (major)", - "matchCategories": [ "helm" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "java dependencies (non major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "java dependencies (major)", - "matchCategories": [ "java" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "js dependencies (non major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "js dependencies (major)", - "matchCategories": [ "js" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "kubernetes dependencies (non major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "kubernetes dependencies (major)", - "matchCategories": [ "kubernetes" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "python dependencies (non major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "python dependencies (major)", - "matchCategories": [ "python" ], - "matchUpdateTypes": [ "major" ] - }, - { - "addLabels": [ "non-major" ], - "groupName": "rust dependencies (non major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "!major" ] - }, - { - "addLabels": [ "major" ], - "groupName": "rust dependencies (major)", - "matchCategories": [ "rust" ], - "matchUpdateTypes": [ "major" ] - }, - ], -} \ No newline at end of file diff --git a/testdata/nodejs/success_options_github/.github/labeler.yml b/testdata/nodejs/success_options_github/.github/labeler.yml deleted file mode 100644 index 80a075d4..00000000 --- a/testdata/nodejs/success_options_github/.github/labeler.yml +++ /dev/null @@ -1,92 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://github.com/marketplace/actions/release-drafter#autolabeler - -autolabeler: - - label: enhancement - title: - - /feat\/.+/ - - /refactor\/.+/ - branch: - - /dev\/.+/ - - - label: breaking - body: - - /.*BREAKING.*/ - - - label: bug - title: - - /fix\/.+/ - - /perf\/.+/ - - /revert\/.+/ - branch: - - /(hot)?fix\/.+/ - - - label: documentation - title: - - /doc(s)?\/.+/ - branch: - - /doc(s)?\/.+/ - files: - - "**/*.md" - - "**/doc.go" - - "**/docs/**" - - - label: chore - title: - - /chore\/.+/ - - - label: test - title: - - /test\/.+/ - branch: - - /test\/.+/ - files: - - "**/*_test.go" - - "**/*.spec.js" - - "**/*.spec.ts" - - "**/*.test.js" - - "**/*.test.ts" - - "**/test/**" - - "**/testdata/**" - - "**/tests/**" - - - label: github_actions - files: - - "action.yml" - - "**/.github/actions/**" - - "**/.github/workflows/**" - - - label: go - files: - - "**/*.go" - - - label: javascript - files: - - "**/*.js" - - "**/*.ts" - - - label: python - files: - - "**/*.py" - - - label: rust - files: - - "**/*.rs" - - - label: shell - files: - - "**/*.sh" - - "**/*.zsh" - - "**/*.bash" - - - label: dependencies - title: - - /.*\(deps\).*/ - # files: - # - "**/go.mod" - # - "**/go.sum" - # - "**/package.json" - -template: | - $CHANGES \ No newline at end of file diff --git a/testdata/nodejs/success_options_github/.github/release.yml b/testdata/nodejs/success_options_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/nodejs/success_options_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/nodejs/success_options_github/.github/workflows/codeql.yml b/testdata/nodejs/success_options_github/.github/workflows/codeql.yml deleted file mode 100644 index d6a8aac2..00000000 --- a/testdata/nodejs/success_options_github/.github/workflows/codeql.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: CodeQL -run-name: CodeQL - -on: - push: - branches: - - alpha - - beta - - dev - - develop - - development - - main - - master - - next - - staging - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - -jobs: - codeql: - name: CodeQL - runs-on: ubuntu-latest - permissions: - security-events: write - strategy: - fail-fast: false - matrix: - language: - - javascript-typescript - steps: - - uses: actions/checkout@v4 - - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - - uses: github/codeql-action/autobuild@v3 - - uses: github/codeql-action/analyze@v3 - with: - category: /language:${{ matrix.language }} \ No newline at end of file diff --git a/testdata/nodejs/success_options_github/.github/workflows/labeler.yml b/testdata/nodejs/success_options_github/.github/workflows/labeler.yml deleted file mode 100644 index a729aada..00000000 --- a/testdata/nodejs/success_options_github/.github/workflows/labeler.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Labeler -run-name: Labeler - -on: - pull_request: # autolabeler on project pull requests - types: - - opened - - reopened - - synchronize - # pull_request_target: # autolabeler on fork pull requests - # types: - # - opened - # - reopened - # - synchronize - -jobs: - - labeler: - name: Labeler - runs-on: ubuntu-latest - permissions: - contents: read # enfore rights to specify no release, even draft, is created - pull-requests: write - steps: - # https://github.com/marketplace/actions/release-drafter - - id: drafter - uses: release-drafter/release-drafter@v6 - with: - commitish: ${{ github.base_ref }} - config-name: labeler.yml - latest: false - name: v$RESOLVED_VERSION - prerelease-identifier: labeler - prerelease: true - publish: false - tag: v$RESOLVED_VERSION - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/testdata/nodejs/success_options_github/.github/workflows/nodejs.yml b/testdata/nodejs/success_options_github/.github/workflows/nodejs.yml deleted file mode 100644 index f36f3afa..00000000 --- a/testdata/nodejs/success_options_github/.github/workflows/nodejs.yml +++ /dev/null @@ -1,151 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Node -run-name: Node - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - workflow_call: - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - node-audit: - name: Node Audit - runs-on: ubuntu-latest - needs: run-workflow - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v4 - with: - cache: pnpm - node-version: lts/* - - run: pnpm audit - - node-lint: - name: Node Lint - runs-on: ubuntu-latest - needs: run-workflow - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v4 - with: - cache: pnpm - node-version: lts/* - - run: mkdir -p reports/ - - run: pnpm install --frozen-lockfile - - run: pnpm run lint -o reports/node-lint.xslint.json -f json - - uses: actions/upload-artifact@v4 - with: - name: lint - path: reports - retention-days: 1 - - node-test: - name: Node Test - runs-on: ${{ matrix.os }} - needs: run-workflow - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - env: - OS: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v4 - with: - cache: pnpm - node-version: lts/* - - run: mkdir -p reports/ - - run: pnpm install-test --frozen-lockfile - - if: ${{ ! startsWith(github.head_ref, 'dependabot') && ! startsWith(github.head_ref, 'renovate') }} - uses: codecov/codecov-action@v4 - with: - codecov_yml_path: .codecov.yml - disable_search: true - env_vars: OS - fail_ci_if_error: false - files: reports/lcov.info - slug: ${{ github.repository }} - token: ${{ secrets.CODECOV_TOKEN }} - - uses: actions/upload-artifact@v4 - with: - name: coverage - path: reports - retention-days: 1 - - sonar-analysis: - name: Sonar Analysis - runs-on: ubuntu-latest - needs: - - run-workflow - - node-lint - - node-test - env: - SONAR_USER_HOME: .sonar - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/download-artifact@v4 - - uses: actions/cache/restore@v4 - with: - path: ${{ env.SONAR_USER_HOME }} - key: sonar-cache - - if: ${{ github.event_name == 'pull_request' }} - uses: sonarsource/sonarcloud-github-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: | - -Dproject.settings=sonar.properties - -Dsonar.pullrequest.base=${{ github.base_ref }} - -Dsonar.pullrequest.branch=${{ github.head_ref }} - -Dsonar.pullrequest.key=${{ github.event.issue.number }} - - if: ${{ github.event_name == 'push' }} - uses: sonarsource/sonarcloud-github-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: | - -Dproject.settings=sonar.properties - -Dsonar.branch.name=${{ github.ref_name }} - - uses: actions/cache/save@v4 - with: - path: ${{ env.SONAR_USER_HOME }} - key: sonar-cache \ No newline at end of file diff --git a/testdata/nodejs/success_options_github/.gitignore b/testdata/nodejs/success_options_github/.gitignore deleted file mode 100644 index ef7f4401..00000000 --- a/testdata/nodejs/success_options_github/.gitignore +++ /dev/null @@ -1,133 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file diff --git a/testdata/nodejs/success_options_github/README.md b/testdata/nodejs/success_options_github/README.md deleted file mode 100644 index 8b65817f..00000000 --- a/testdata/nodejs/success_options_github/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Coverage - Coverage -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_options_github/sonar.properties b/testdata/nodejs/success_options_github/sonar.properties deleted file mode 100644 index 8c4f2abc..00000000 --- a/testdata/nodejs/success_options_github/sonar.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -sonar.host.url=https://sonarcloud.io -sonar.qualitygate.wait=true - -sonar.organization=maintainer name -sonar.projectBaseDir=. -sonar.projectKey=kilianpaquier_craft -sonar.projectName=craft - -sonar.exclusions=node_modules/**,dist/**,**/*.spec.js,**/*.spec.ts,**/*.test.js,**/*.test.ts -sonar.test.inclusions=**/*.spec.js,**/*.spec.ts,**/*.test.js,**/*.test.ts - -sonar.testExecutionReportPaths=reports/node-test.sonar.xml -sonar.eslint.reportPaths=reports/node-lint.xslint.json -sonar.javascript.lcov.reportPaths=reports/lcov.info \ No newline at end of file diff --git a/testdata/nodejs/success_options_gitlab/.gitignore b/testdata/nodejs/success_options_gitlab/.gitignore deleted file mode 100644 index ef7f4401..00000000 --- a/testdata/nodejs/success_options_gitlab/.gitignore +++ /dev/null @@ -1,133 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file diff --git a/testdata/nodejs/success_options_gitlab/.gitlab-ci.yml b/testdata/nodejs/success_options_gitlab/.gitlab-ci.yml deleted file mode 100644 index 71988199..00000000 --- a/testdata/nodejs/success_options_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -# SONAR_TOKEN: SonarQube authentication token (depends on your authentication method) -# SONAR_LOGIN: SonarQube login (depends on your authentication method) -# SONAR_PASSWORD: SonarQube password (depends on your authentication method) - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/nodejs/success_options_gitlab/.gitlab/semrel-plugins.txt b/testdata/nodejs/success_options_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index f8ef81c1..00000000 --- a/testdata/nodejs/success_options_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,8 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/npm -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/nodejs/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/nodejs/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index 0215177f..00000000 --- a/testdata/nodejs/success_options_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,85 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # Node.js template - - project: "to-be-continuous/node" - ref: "3" - file: "templates/gitlab-ci-node.yml" - - # SonarQube template - - project: "to-be-continuous/sonar" - ref: "4" - file: "templates/gitlab-ci-sonar.yml" - -variables: - - NODE_AUDIT_DISABLED: "false" - NODE_BUILD_ARGS: "run build --prod" - NODE_IMAGE: "registry.hub.docker.com/library/node:lts-alpine" - NODE_LINT_ARGS: "run lint" - NODE_LINT_ENABLED: "true" - NODE_OUTDATED_ARGS: "--long" - NODE_OUTDATED_DISABLED: "false" - NODE_PUBLISH_ENABLED: "false" - NODE_SBOM_DISABLED: "true" - NODE_SEMGREP_DISABLED: "false" # https://semgrep.dev/docs/ - NODE_TEST_ARGS: "test -- --coverage" - - SONAR_HOST_URL: "https://sonarcloud.io" - SONAR_BASE_ARGS: | - -Dsonar.properties=sonar.properties - -Dsonar.links.homepage=${CI_PROJECT_URL} - -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines - -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues - SONAR_QUALITY_GATE_ENABLED: "true" - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" \ No newline at end of file diff --git a/testdata/nodejs/success_options_gitlab/README.md b/testdata/nodejs/success_options_gitlab/README.md deleted file mode 100644 index 8a8c43ad..00000000 --- a/testdata/nodejs/success_options_gitlab/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues - Coverage - Coverage -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_options_gitlab/sonar.properties b/testdata/nodejs/success_options_gitlab/sonar.properties deleted file mode 100644 index 8c4f2abc..00000000 --- a/testdata/nodejs/success_options_gitlab/sonar.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -sonar.host.url=https://sonarcloud.io -sonar.qualitygate.wait=true - -sonar.organization=maintainer name -sonar.projectBaseDir=. -sonar.projectKey=kilianpaquier_craft -sonar.projectName=craft - -sonar.exclusions=node_modules/**,dist/**,**/*.spec.js,**/*.spec.ts,**/*.test.js,**/*.test.ts -sonar.test.inclusions=**/*.spec.js,**/*.spec.ts,**/*.test.js,**/*.test.ts - -sonar.testExecutionReportPaths=reports/node-test.sonar.xml -sonar.eslint.reportPaths=reports/node-lint.xslint.json -sonar.javascript.lcov.reportPaths=reports/lcov.info \ No newline at end of file diff --git a/testdata/nodejs/success_release_github/.github/actions/version/action.yml b/testdata/nodejs/success_release_github/.github/actions/version/action.yml deleted file mode 100644 index 16fc2f58..00000000 --- a/testdata/nodejs/success_release_github/.github/actions/version/action.yml +++ /dev/null @@ -1,105 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Version -description: Compute the next release version or release it - -inputs: - download_dist: - description: Whether to build artifact into dist folder or not - default: "false" - mode: - description: | - Action mode: - - "dry_run" to only get the next version number - - "draft" to get the next version number and create draft pull requests and releases - - "release" to get the next version number and create pull requests, tags and releases - required: true - token: - description: GitHub access token - required: true - npm_token: - description: Access token for the npm registry - required: true - -outputs: - branch_sha: - description: The concerned branch sha256 value - value: ${{ steps.version.outputs.branch_sha }} - release: - description: Whether a release can be made or not - value: ${{ steps.version.outputs.release }} - version: - description: The computed version - value: ${{ steps.version.outputs.version }} - -runs: - using: composite - steps: - - shell: bash - run: | - if [ "${MODE}" != "dry_run" ] && [ "${MODE}" != "draft" ] && [ "${MODE}" != "release" ]; then - echo "invalid input mode '${MODE}', must be one of 'dry_run', 'draft', 'release'" - exit 2 - fi - - if [ "${MODE}" != "dry_run" ] && [ "${GITHUB_REF_PROTECTED}" != "true" ]; then - echo "invalid input mode '${MODE}', can't be 'draft' or 'release' when github branch isn't protected" - fi - env: - MODE: ${{ inputs.mode }} - - if: ${{ inputs.download_dist == 'true' }} - uses: actions/download-artifact@v4 - with: - name: build - path: dist - # https://github.com/marketplace/actions/action-for-semantic-release - - id: semrel_version - continue-on-error: true - uses: cycjimmy/semantic-release-action@v4 - with: - semantic_version: 24 - extra_plugins: | - @semantic-release/changelog - @semantic-release/commit-analyzer - @semantic-release/exec - @semantic-release/git - @semantic-release/github - @semantic-release/npm - @semantic-release/release-notes-generator - conventional-changelog-conventionalcommits - dry_run: ${{ inputs.mode != 'release' }} - env: - GITHUB_TOKEN: ${{ inputs.token }} - NPM_TOKEN: ${{ inputs.npm_token }} - - id: version - shell: bash - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "version=v${SEMREL_INFO_NEXT_VERSION}" >> $GITHUB_OUTPUT - if echo "${SEMREL_INFO_NEXT_VERSION}" | grep -Eq "^[0-9]+(\.[0-9]+){2}$"; then - echo "release=true" >> $GITHUB_OUTPUT - else - echo "release=false" >> $GITHUB_OUTPUT - fi - exit 0 - fi - - git fetch --tags - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> $GITHUB_OUTPUT - echo "release=false" >> $GITHUB_OUTPUT - env: - SEMREL_INFO_LAST_VERSION: ${{ steps.semrel_version.outputs.last_release_version }} - SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }} - - shell: bash - run: echo $VERSION - env: - VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/testdata/nodejs/success_release_github/.github/release.yml b/testdata/nodejs/success_release_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/nodejs/success_release_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/nodejs/success_release_github/.github/workflows/nodejs.yml b/testdata/nodejs/success_release_github/.github/workflows/nodejs.yml deleted file mode 100644 index a3fc23b9..00000000 --- a/testdata/nodejs/success_release_github/.github/workflows/nodejs.yml +++ /dev/null @@ -1,74 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Node -run-name: Node - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - workflow_call: - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - node-lint: - name: Node Lint - runs-on: ubuntu-latest - needs: run-workflow - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version-file: package.json - - run: mkdir -p reports/ - - run: bun install --frozen-lockfile - - run: bun run lint -o reports/node-lint.xslint.json -f json - - node-test: - name: Node Test - runs-on: ${{ matrix.os }} - needs: run-workflow - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - env: - OS: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version-file: package.json - - run: mkdir -p reports/ - - run: bun install --frozen-lockfile - - run: bun test --rerun-each 10 --coverage --coverage-reporter=lcov --coverage-dir=reports \ No newline at end of file diff --git a/testdata/nodejs/success_release_github/.github/workflows/release.yml b/testdata/nodejs/success_release_github/.github/workflows/release.yml deleted file mode 100644 index 5dd47c64..00000000 --- a/testdata/nodejs/success_release_github/.github/workflows/release.yml +++ /dev/null @@ -1,75 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Release -run-name: Release - -on: - workflow_dispatch: - inputs: - mode: - description: Whether to only make a dry_run or to make the release completely - type: choice - default: dry_run - options: - - dry_run - - release - -jobs: - - version: - name: Version - runs-on: ubuntu-latest - if: ${{ github.ref_protected }} - environment: release - permissions: - contents: write - issues: write - pull-requests: write - id-token: write - outputs: - mode: ${{ steps.mode.outputs.mode }} - release: ${{ steps.version.outputs.release }} - version: ${{ steps.version.outputs.version }} - steps: - - uses: actions/checkout@v4 - - id: version - uses: ./.github/actions/version - with: - mode: dry_run # compute only the version to build - token: ${{ secrets.GITHUB_TOKEN }} - npm_token: ${{ secrets.NPM_TOKEN }} - - id: mode - run: | - if [ "$GITHUB_EVENT_NAME" = "push" ]; then - echo "mode=release" >> $GITHUB_OUTPUT - exit 0 - fi - echo "mode=${INPUT_MODE}" >> $GITHUB_OUTPUT - env: - INPUT_MODE: ${{ inputs.mode }} - - node: - name: Node - uses: ./.github/workflows/nodejs.yml - secrets: inherit - - release: - name: Release - runs-on: ubuntu-latest - environment: release - permissions: - contents: write - issues: write - pull-requests: write - id-token: write - needs: - - version - - node - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/version - with: - download_dist: true - mode: ${{ needs.version.outputs.mode }} - token: ${{ secrets.GITHUB_TOKEN }} - npm_token: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/testdata/nodejs/success_release_github/.gitignore b/testdata/nodejs/success_release_github/.gitignore deleted file mode 100644 index ef7f4401..00000000 --- a/testdata/nodejs/success_release_github/.gitignore +++ /dev/null @@ -1,133 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file diff --git a/testdata/nodejs/success_release_github/.releaserc.yml b/testdata/nodejs/success_release_github/.releaserc.yml deleted file mode 100644 index 4bac473b..00000000 --- a/testdata/nodejs/success_release_github/.releaserc.yml +++ /dev/null @@ -1,92 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://semantic-release.gitbook.io/semantic-release/usage/configuration - -branches: - - (master|main) - - v+([0-9])?(.{+([0-9]),x}).x - - name: next - prerelease: true - - name: beta - prerelease: true - - name: alpha - prerelease: true - - name: staging - prerelease: beta - - name: (dev|develop|development) - prerelease: alpha - -tagFormat: v${version} - -plugins: - - - "@semantic-release/commit-analyzer" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - releaseRules: - - { breaking: true, release: major } - - { revert: true, release: patch } - - { type: feat, release: minor } - - { type: fix, release: patch } - - { type: revert, release: patch } - - { type: perf, release: patch } - - { type: docs, release: patch } - - { type: chore, release: patch } - - { type: refactor, release: minor } - - - { scope: release, release: false } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - - "@semantic-release/release-notes-generator" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - "@semantic-release/changelog" - - "@semantic-release/npm" - - - "@semantic-release/git" - - assets: - - CHANGELOG.md - - package.json - message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - - - "@semantic-release/github" - - draftRelease: false - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} - failCommentCondition: <% return false; %> - successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 - successCommentCondition: <% return true; %> - assets: - - label: CHANGELOG.md - path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file diff --git a/testdata/nodejs/success_release_github/README.md b/testdata/nodejs/success_release_github/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/nodejs/success_release_github/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_release_gitlab/.gitignore b/testdata/nodejs/success_release_gitlab/.gitignore deleted file mode 100644 index ef7f4401..00000000 --- a/testdata/nodejs/success_release_gitlab/.gitignore +++ /dev/null @@ -1,133 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file diff --git a/testdata/nodejs/success_release_gitlab/.gitlab-ci.yml b/testdata/nodejs/success_release_gitlab/.gitlab-ci.yml deleted file mode 100644 index 37bcd914..00000000 --- a/testdata/nodejs/success_release_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/nodejs/success_release_gitlab/.gitlab/semrel-plugins.txt b/testdata/nodejs/success_release_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index f8ef81c1..00000000 --- a/testdata/nodejs/success_release_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,8 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/npm -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/nodejs/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/nodejs/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index a871a92f..00000000 --- a/testdata/nodejs/success_release_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,72 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # Node.js template - - project: "to-be-continuous/node" - ref: "3" - file: "templates/gitlab-ci-node.yml" - -variables: - - NODE_AUDIT_DISABLED: "false" - NODE_BUILD_ARGS: "run build --prod" - NODE_IMAGE: "registry.hub.docker.com/library/node:lts-alpine" - NODE_LINT_ARGS: "run lint" - NODE_LINT_ENABLED: "true" - NODE_OUTDATED_ARGS: "--long" - NODE_OUTDATED_DISABLED: "false" - NODE_PUBLISH_ENABLED: "false" - NODE_SBOM_DISABLED: "true" - NODE_SEMGREP_DISABLED: "false" # https://semgrep.dev/docs/ - NODE_TEST_ARGS: "test -- --coverage" - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "false" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" \ No newline at end of file diff --git a/testdata/nodejs/success_release_gitlab/.releaserc.yml b/testdata/nodejs/success_release_gitlab/.releaserc.yml deleted file mode 100644 index 1548a50f..00000000 --- a/testdata/nodejs/success_release_gitlab/.releaserc.yml +++ /dev/null @@ -1,91 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://semantic-release.gitbook.io/semantic-release/usage/configuration - -branches: - - (master|main) - - v+([0-9])?(.{+([0-9]),x}).x - - name: next - prerelease: true - - name: beta - prerelease: true - - name: alpha - prerelease: true - - name: staging - prerelease: beta - - name: (dev|develop|development) - prerelease: alpha - -tagFormat: v${version} - -plugins: - - - "@semantic-release/commit-analyzer" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - releaseRules: - - { breaking: true, release: major } - - { revert: true, release: patch } - - { type: feat, release: minor } - - { type: fix, release: patch } - - { type: revert, release: patch } - - { type: perf, release: patch } - - { type: docs, release: patch } - - { type: chore, release: patch } - - { type: refactor, release: minor } - - - { scope: release, release: false } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - - "@semantic-release/release-notes-generator" - - preset: conventionalcommits - presetConfig: - types: - - { type: feat, section: "🚀 Features" } - - { type: fix, section: "🐛 Bug Fixes" } - - { type: revert, section: "⏪ Reverts" } - - { type: perf, section: "💪 Performance Improvements" } - - { type: docs, section: "📚 Documentation" } - - { type: chore, section: "⚙️ Chores" } - - { type: refactor, section: "🚜 Code Refactoring" } - - - { type: build, section: "🏗️ Build System", hidden: true } - - { type: ci, section: "♾️ Continuous Integration", hidden: true } - - { type: style, section: "Styles", hidden: true } - - { type: test, section: "Tests", hidden: true } - parserOpts: - noteKeywords: - - BREAKING CHANGE - - BREAKING CHANGES - - BREAKING - - "@semantic-release/changelog" - - "@semantic-release/npm" - - - "@semantic-release/git" - - assets: - - CHANGELOG.md - - package.json - message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - - - "@semantic-release/gitlab" - - failComment: ⚠️ Expected release for branch '${branch.name}' has failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')} - failCommentCondition: <% return false; %> - successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉 - successCommentCondition: <% return true; %> - assets: - - label: CHANGELOG.md - path: CHANGELOG.md - - "@semantic-release/exec" \ No newline at end of file diff --git a/testdata/nodejs/success_release_gitlab/README.md b/testdata/nodejs/success_release_gitlab/README.md deleted file mode 100644 index 87fcdf98..00000000 --- a/testdata/nodejs/success_release_gitlab/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_github/.github/release.yml b/testdata/nodejs/success_static_netlify_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/nodejs/success_static_netlify_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_github/.github/workflows/netlify.yml b/testdata/nodejs/success_static_netlify_github/.github/workflows/netlify.yml deleted file mode 100644 index 6a84f494..00000000 --- a/testdata/nodejs/success_static_netlify_github/.github/workflows/netlify.yml +++ /dev/null @@ -1,53 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Netlify -run-name: Netlify - -on: - workflow_call: - workflow_dispatch: - -jobs: - - node: - name: Node - uses: ./.github/workflows/nodejs.yml - with: - build: true - - netlify: - name: Netlify - runs-on: ubuntu-latest - environment: - name: netlify - url: ${{ steps.netlify.outputs.deploy-url }} - permissions: - deployments: write - pull-requests: write - needs: - - node - steps: - - uses: actions/checkout@v4 - - id: branch_sha - run: | - BRANCH_SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - echo "branch_sha=${BRANCH_SHA}" >> $GITHUB_OUTPUT - - uses: actions/download-artifact@v4 - with: - name: build - path: dist - - id: netlify - uses: nwtgck/actions-netlify@v3 - with: - alias: ${{ steps.branch_sha.outputs.branch_sha }} - deploy-message: ${{ github.ref_name }} - enable-commit-comment: false - enable-commit-status: false - github-deployment-environment: netlify - github-token: ${{ secrets.GITHUB_TOKEN }} - netlify-config-path: netlify.toml - production-branch: ${{ github.event.repository.default_branch }} - publish-dir: dist - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_github/.github/workflows/nodejs.yml b/testdata/nodejs/success_static_netlify_github/.github/workflows/nodejs.yml deleted file mode 100644 index c211c960..00000000 --- a/testdata/nodejs/success_static_netlify_github/.github/workflows/nodejs.yml +++ /dev/null @@ -1,99 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Node -run-name: Node - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - workflow_call: - inputs: - build: - description: Whether to run build job or not - required: false - type: boolean - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - node-lint: - name: Node Lint - runs-on: ubuntu-latest - needs: run-workflow - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version-file: package.json - - run: mkdir -p reports/ - - run: bun install --frozen-lockfile - - run: bun run lint -o reports/node-lint.xslint.json -f json - - node-test: - name: Node Test - runs-on: ${{ matrix.os }} - needs: run-workflow - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - env: - OS: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version-file: package.json - - run: mkdir -p reports/ - - run: bun install --frozen-lockfile - - run: bun test --rerun-each 10 --coverage --coverage-reporter=lcov --coverage-dir=reports - - node-build: - name: Node Build - runs-on: ubuntu-latest - if: ${{ inputs.build }} - needs: - - run-workflow - - node-test - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version-file: package.json - - run: bun install --frozen-lockfile - - run: bun run build - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist - retention-days: 1 \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_github/.gitignore b/testdata/nodejs/success_static_netlify_github/.gitignore deleted file mode 100644 index 357b6739..00000000 --- a/testdata/nodejs/success_static_netlify_github/.gitignore +++ /dev/null @@ -1,136 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# Local Netlify folder -.netlify \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_github/README.md b/testdata/nodejs/success_static_netlify_github/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/nodejs/success_static_netlify_github/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_gitlab/.gitignore b/testdata/nodejs/success_static_netlify_gitlab/.gitignore deleted file mode 100644 index 357b6739..00000000 --- a/testdata/nodejs/success_static_netlify_gitlab/.gitignore +++ /dev/null @@ -1,136 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# Local Netlify folder -.netlify \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_gitlab/.gitlab-ci.yml b/testdata/nodejs/success_static_netlify_gitlab/.gitlab-ci.yml deleted file mode 100644 index 802b11f5..00000000 --- a/testdata/nodejs/success_static_netlify_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -# NETLIFY_SITE_ID: The netlify site ID where builds will be published (should be retrieved if the project name is the same here https://app.netlify.com/sites/craft/configuration/general) -# NETLIFY_AUTH_TOKEN: The netlify authentication token (it's a personal token) to use for deployments (once connected, can be retrieved here https://app.netlify.com/user/applications#content) - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_gitlab/.gitlab/semrel-plugins.txt b/testdata/nodejs/success_static_netlify_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index f8ef81c1..00000000 --- a/testdata/nodejs/success_static_netlify_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,8 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/npm -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/nodejs/success_static_netlify_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index e5425b5e..00000000 --- a/testdata/nodejs/success_static_netlify_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,95 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # Node.js template - - project: "to-be-continuous/node" - ref: "3" - file: "templates/gitlab-ci-node.yml" - -variables: - - NODE_AUDIT_DISABLED: "false" - NODE_BUILD_ARGS: "run build --prod" - NODE_IMAGE: "registry.hub.docker.com/library/node:lts-alpine" - NODE_LINT_ARGS: "run lint" - NODE_LINT_ENABLED: "true" - NODE_OUTDATED_ARGS: "--long" - NODE_OUTDATED_DISABLED: "false" - NODE_PUBLISH_ENABLED: "false" - NODE_SBOM_DISABLED: "true" - NODE_SEMGREP_DISABLED: "false" # https://semgrep.dev/docs/ - NODE_TEST_ARGS: "test -- --coverage" - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -netlify: - stage: deploy - image: node:lts-alpine - environment: - name: $ENV - action: start - variables: - DIST_FOLDER: dist - rules: - - if: $CI_COMMIT_REF_PROTECTED == 'true' - variables: - ARGS: "--prod" - ENV: production - when: manual - - variables: - ARGS: "--alias $BRANCH_SHA" # sha is coming from version.yml file with export from semantic-release-info job - ENV: $CI_COMMIT_REF_NAME - when: manual - before_script: - - npm install -g netlify-cli - script: - - netlify deploy --site "$NETLIFY_SITE_ID" --auth "$NETLIFY_AUTH_TOKEN" --dir "$DIST_FOLDER" "$ARGS" \ No newline at end of file diff --git a/testdata/nodejs/success_static_netlify_gitlab/README.md b/testdata/nodejs/success_static_netlify_gitlab/README.md deleted file mode 100644 index 87fcdf98..00000000 --- a/testdata/nodejs/success_static_netlify_gitlab/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_github/.github/release.yml b/testdata/nodejs/success_static_pages_github/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/nodejs/success_static_pages_github/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_github/.github/workflows/nodejs.yml b/testdata/nodejs/success_static_pages_github/.github/workflows/nodejs.yml deleted file mode 100644 index beecdc19..00000000 --- a/testdata/nodejs/success_static_pages_github/.github/workflows/nodejs.yml +++ /dev/null @@ -1,104 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Node -run-name: Node - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - push: - branches: - - alpha - - beta - - dev - - develop - - development - - next - - staging - - main - - master - - v[0-9]+.[0-9]+.x - - v[0-9]+.x - workflow_call: - inputs: - build: - description: Whether to run build job or not - required: false - type: boolean - workflow_dispatch: - -jobs: - - run-workflow: - name: Run Workflow - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} - outputs: - skip: ${{ steps.skip.outputs.skip }} - steps: - - id: skip - run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT - - node-lint: - name: Node Lint - runs-on: ubuntu-latest - needs: run-workflow - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version-file: package.json - - run: mkdir -p reports/ - - run: bun install --frozen-lockfile - - run: bun run lint -o reports/node-lint.xslint.json -f json - - node-test: - name: Node Test - runs-on: ${{ matrix.os }} - needs: run-workflow - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - env: - OS: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version-file: package.json - - run: mkdir -p reports/ - - run: bun install --frozen-lockfile - - run: bun test --rerun-each 10 --coverage --coverage-reporter=lcov --coverage-dir=reports - - node-build: - name: Node Build - runs-on: ubuntu-latest - if: ${{ inputs.build }} - needs: - - run-workflow - - node-test - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version-file: package.json - - run: bun install --frozen-lockfile - - run: bun run build - - uses: actions/upload-pages-artifact@v3 - with: - name: github-pages - path: dist - retention-days: 1 - - uses: actions/upload-artifact@v4 - with: - name: build - path: dist - retention-days: 1 \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_github/.github/workflows/pages.yml b/testdata/nodejs/success_static_pages_github/.github/workflows/pages.yml deleted file mode 100644 index c831fdca..00000000 --- a/testdata/nodejs/success_static_pages_github/.github/workflows/pages.yml +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -name: Pages -run-name: Pages - -on: - workflow_call: - workflow_dispatch: - -jobs: - - node: - name: Node - uses: ./.github/workflows/nodejs.yml - with: - build: true - - pages: - name: Pages - runs-on: ubuntu-latest - needs: - - node - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - permissions: - pages: write - id-token: write - steps: - - id: deployment - uses: actions/deploy-pages@v4 - with: - artifact_name: github-pages - preview: ${{ github.ref_name != github.event.repository.default_branch }} \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_github/.gitignore b/testdata/nodejs/success_static_pages_github/.gitignore deleted file mode 100644 index ef7f4401..00000000 --- a/testdata/nodejs/success_static_pages_github/.gitignore +++ /dev/null @@ -1,133 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_github/README.md b/testdata/nodejs/success_static_pages_github/README.md deleted file mode 100644 index de002d18..00000000 --- a/testdata/nodejs/success_static_pages_github/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_gitlab/.gitignore b/testdata/nodejs/success_static_pages_gitlab/.gitignore deleted file mode 100644 index ef7f4401..00000000 --- a/testdata/nodejs/success_static_pages_gitlab/.gitignore +++ /dev/null @@ -1,133 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_gitlab/.gitlab-ci.yml b/testdata/nodejs/success_static_pages_gitlab/.gitlab-ci.yml deleted file mode 100644 index 37bcd914..00000000 --- a/testdata/nodejs/success_static_pages_gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - ---- -include: .gitlab/workflows/.gitlab-ci.yml - -# secret variables -# (define the variables below in your GitLab group/project variables) - -# GITLAB_TOKEN: A GitLab 'project access token' or 'personal access token' with `api`, `read_repository` and `write_repository` scopes. -# SEMREL_GPG_SIGNKEY: Path to the GPG signkey exported with `gpg --armor --export-secret-key` (optional). - -variables: - PROD_REF: /^(master|main)$/ - SEMREL_BRANCHES_REF: /^(master|main|v[0-9]+\.x|v[0-9]+\.[0-9]+\.x|next|alpha|beta|staging|dev|develop|development)$/ - INTEG_REF: /^(staging|dev|develop|development)$/ \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_gitlab/.gitlab/semrel-plugins.txt b/testdata/nodejs/success_static_pages_gitlab/.gitlab/semrel-plugins.txt deleted file mode 100644 index f8ef81c1..00000000 --- a/testdata/nodejs/success_static_pages_gitlab/.gitlab/semrel-plugins.txt +++ /dev/null @@ -1,8 +0,0 @@ -@semantic-release/changelog -@semantic-release/commit-analyzer -@semantic-release/exec -@semantic-release/git -@semantic-release/gitlab -@semantic-release/npm -@semantic-release/release-notes-generator -conventional-changelog-conventionalcommits \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_gitlab/.gitlab/workflows/.gitlab-ci.yml b/testdata/nodejs/success_static_pages_gitlab/.gitlab/workflows/.gitlab-ci.yml deleted file mode 100644 index a8d546a1..00000000 --- a/testdata/nodejs/success_static_pages_gitlab/.gitlab/workflows/.gitlab-ci.yml +++ /dev/null @@ -1,96 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - ---- -include: - - # semantic-release template - - project: "to-be-continuous/semantic-release" - ref: "3" - file: "templates/gitlab-ci-semrel.yml" - - # Node.js template - - project: "to-be-continuous/node" - ref: "3" - file: "templates/gitlab-ci-node.yml" - -variables: - - NODE_AUDIT_DISABLED: "false" - NODE_BUILD_ARGS: "run build --prod" - NODE_IMAGE: "registry.hub.docker.com/library/node:lts-alpine" - NODE_LINT_ARGS: "run lint" - NODE_LINT_ENABLED: "true" - NODE_OUTDATED_ARGS: "--long" - NODE_OUTDATED_DISABLED: "false" - NODE_PUBLISH_ENABLED: "false" - NODE_SBOM_DISABLED: "true" - NODE_SEMGREP_DISABLED: "false" # https://semgrep.dev/docs/ - NODE_TEST_ARGS: "test -- --coverage" - - GIT_AUTHOR_EMAIL: ${GITLAB_USER_EMAIL} - GIT_COMMITTER_EMAIL: ${GITLAB_USER_EMAIL} - - SEMREL_TAG_FORMAT: v$${version} - SEMREL_REQUIRED_PLUGINS_FILE: .gitlab/semrel-plugins.txt - SEMREL_HOOKS_DIR: scripts - SEMREL_INFO_ON: all - SEMREL_RELEASE_DISABLED: "true" - SEMREL_AUTO_RELEASE_ENABLED: "false" - -semantic-release-info: - after_script: - - source "${SEMREL_CONFIG_DIR}/semrel.out.env" && rm "${SEMREL_CONFIG_DIR}/semrel.out.env" - - BRANCH_SHA=$(echo "${CI_COMMIT_REF_NAME}" | sha256sum | cut -c -8) - - echo "BRANCH_SHA=${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - > - if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION=v$SEMREL_INFO_NEXT_VERSION" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - echo "SEMREL_INFO_NEXT_VERSION_TYPE=${SEMREL_INFO_NEXT_VERSION_TYPE}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - exit 0 - fi - - git fetch --tags - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "" ]; then - if echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - elif echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" | grep -Eq "^v[0-9]+\.[0-9]+\.x$"; then - SEARCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME%%.x*}" - fi - fi - - SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) - - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} - SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} - - - echo "SEMREL_INFO_LAST_VERSION=v${SEMREL_INFO_LAST_VERSION#v}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION=v${SEMREL_INFO_NEXT_VERSION#v}-build.${BRANCH_SHA}" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - echo "SEMREL_INFO_NEXT_VERSION_TYPE=build" >> "${SEMREL_CONFIG_DIR}/semrel.out.env" - - cat "${SEMREL_CONFIG_DIR}/semrel.out.env" - -pages: - stage: deploy - environment: - name: $ENV - action: start - url: $CI_PAGES_URL - variables: - ENV: production - DIST_FOLDER: dist - rules: - - if: $CI_COMMIT_REF_PROTECTED == 'true' - when: manual - script: - - > - if [ "$DIST_FOLDER" != "public" ]; then - mkdir -p public - $DIST_FOLDER/* public - fi - artifacts: - name: $ENV - paths: - - public - expire_in: 1 day \ No newline at end of file diff --git a/testdata/nodejs/success_static_pages_gitlab/README.md b/testdata/nodejs/success_static_pages_gitlab/README.md deleted file mode 100644 index 87fcdf98..00000000 --- a/testdata/nodejs/success_static_pages_gitlab/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitLab Release - GitLab Issues -

- ---- \ No newline at end of file diff --git a/testdata/run/generic/.github/release.yml b/testdata/run/generic/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/run/generic/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/run/generic/Makefile b/testdata/run/generic/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/run/generic/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/run/generic/README.md b/testdata/run/generic/README.md deleted file mode 100644 index 52fb434b..00000000 --- a/testdata/run/generic/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# . - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/run/generic/scripts/craft.mk b/testdata/run/generic/scripts/craft.mk deleted file mode 100644 index 2079690f..00000000 --- a/testdata/run/generic/scripts/craft.mk +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/run/golang/.github/release.yml b/testdata/run/golang/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/run/golang/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/run/golang/.gitignore b/testdata/run/golang/.gitignore deleted file mode 100644 index 51c2c8b1..00000000 --- a/testdata/run/golang/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs -*.exe -*.exe~ -*.dll -*.so -*.dylib -dist - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# reports -reports/ - -# configs -.env - -# binaries \ No newline at end of file diff --git a/testdata/run/golang/.golangci.yml b/testdata/run/golang/.golangci.yml deleted file mode 100644 index 16247ac7..00000000 --- a/testdata/run/golang/.golangci.yml +++ /dev/null @@ -1,408 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# all available settings of specific linters -linters-settings: - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 20 - - decorder: - # Required order of `type`, `const`, `var` and `func` declarations inside a file. - # Default: types before constants before variables before functions. - dec-order: - - const - - var - - type - - func - # If true, order of declarations is not checked at all. - # Default: true (disabled) - disable-dec-order-check: true - # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). - # Default: true (disabled) - disable-init-func-first-check: true - - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: true - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: 80 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: 60 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(github.com/kilianpaquier/craft) # Custom section: groups all imports with the specified Prefix. - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 30 - - gosec: - # Exclude generated files - # Default: false - exclude-generated: true - - govet: - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `go tool vet help` to see all analyzers. - # Default: [] - disable: - - fieldalignment - - shadow - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Default: [] - ignore-words: [] - - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true - - paralleltest: - # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. - # Default: false - ignore-missing: true - # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are - # still required to have `t.Parallel`, but subtests are allowed to skip it. - # Default: false - ignore-missing-subtests: true - - perfsprint: - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: true - # Optimizes `fmt.Sprintf` with only one argument - # Default: true - sprintf1: true - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: true - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: true - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true - - revive: - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md - rules: - - name: argument-limit - arguments: [6] - - name: atomic - - name: blank-imports - - name: bool-literal-in-expr - - name: call-to-gc - - name: comment-spacings - - name: confusing-naming - - name: confusing-results - - name: constant-logical-expr - - name: context-as-argument - - name: context-keys-type - - name: datarace - - name: deep-exit - - name: defer - - name: dot-imports - - name: duplicated-imports - - name: early-return - - name: empty-block - - name: empty-lines - - name: enforce-map-style - arguments: - - literal - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters - - name: flag-parameter - - name: function-result-limit - arguments: [3] - - name: get-return - - name: identical-branches - - name: if-return - - name: increment-decrement - - name: indent-error-flow - - name: import-alias-naming - arguments: - - "^[a-z_][a-z_0-9]{0,}$" - - name: imports-blocklist - - name: import-shadowing - - name: max-public-structs - arguments: [8] - - name: modifies-parameter - - name: modifies-value-receiver - - name: optimize-operands-order - # - name: package-comments - - name: range - - name: range-val-in-closure - - name: range-val-address - - name: receiver-naming - - name: redundant-import-alias - - name: redefines-builtin-id - - name: string-of-int - - name: string-format - arguments: - - - 'fmt.Errorf[0]' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - - name: struct-tag - - name: superfluous-else - - name: time-equal - - name: time-naming - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - upperCaseConst: true # allow const variables to be uppercase - - name: var-naming - arguments: - - [] # AllowList - - [] # DenyList - - - skipPackageNameChecks: true # allow packages name with "_" - - name: var-declaration - - name: unconditional-recursion - - name: unexported-naming - - name: unexported-return - - name: unhandled-error - arguments: - - bytes.Buffer.Write.* - - fmt.Print - - fmt.Printf - - fmt.Println - - name: unnecessary-stmt - - name: unreachable-code - - name: unused-parameter - arguments: - - allowRegex: "^_" - - name: unused-receiver - arguments: - - allowRegex: "^_" - - name: useless-break - - name: waitgroup-by-value - - tagalign: - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - builder - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - testifylint: - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^NoErrorf?$ - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 10 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # - # Default: [] - ignore-decls: - - o options - - T any - - t testing.T - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true - -issues: - include: - # revive:exported enforce revive comments on exported types - - EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported - - EXC0014 # comment on exported (.+) should be of the form "(.+)..." - - # revive:package-comments enforce revive comments on packages - # - EXC0013 # package comment should be of the form "(.+)... - # - EXC0015 # should have a package comment - exclude: - - G303 # file creation in shared tmp directory without using os.CreateTemp - - G306 # Expect WriteFile permissions to be 0600 or less - - ST1003 # already covered by revive var-naming linter (package naming constraints) - exclude-rules: - # disable funlen for all _test.go files - - path: _test.go - linters: - - dupl - - funlen - - goconst - - maintidx - # Maximum issues count per one linter. - # Set to 0 to disable. - # Default: 50 - max-issues-per-linter: 0 - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 - max-same-issues: 0 - -linters: - # please, do not use `enable-all`: it's deprecated and will be removed soon. - # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint - disable-all: true - enable: - - asasalint - - bodyclose - - canonicalheader - - containedctx - - contextcheck - - copyloopvar - - cyclop - - decorder - - dogsled - - dupl - - durationcheck - - errcheck - - errname - - errorlint - - exhaustive - - fatcontext - - forbidigo - - forcetypeassert - - funlen - - gci - - gocheckcompilerdirectives - - gocognit - - goconst - - gocritic - - gocyclo - - godox - - gofumpt - - goprintffuncname - - gosec - - gosimple - - govet - - grouper - - importas - - inamedparam - - ineffassign - - interfacebloat - - intrange - - maintidx - - makezero - - mirror - - misspell - - musttag - - nakedret - - nestif - - nilerr - - nilnil - - noctx - - nolintlint - - nosprintfhostport - - paralleltest - - perfsprint - - prealloc - - predeclared - - reassign - - revive - - rowserrcheck - - sloglint - - spancheck - - sqlclosecheck - - staticcheck - - stylecheck - - tagalign - - tenv - - testableexamples - - testifylint - - testpackage - - thelper - - tparallel - - typecheck - - unconvert - - unused - - usestdlibvars - - varnamelen - - wastedassign - - whitespace - - wrapcheck \ No newline at end of file diff --git a/testdata/run/golang/Makefile b/testdata/run/golang/Makefile deleted file mode 100644 index b40311bc..00000000 --- a/testdata/run/golang/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# Code generated by craft; DO NOT EDIT. -# Unless the above comment is removed to avoid generation. - -include ./scripts/*.mk \ No newline at end of file diff --git a/testdata/run/golang/README.md b/testdata/run/golang/README.md deleted file mode 100644 index 55010a4e..00000000 --- a/testdata/run/golang/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version - Go Report Card -

- ---- \ No newline at end of file diff --git a/testdata/run/golang/chart/.craft b/testdata/run/golang/chart/.craft deleted file mode 100644 index 4641bece..00000000 --- a/testdata/run/golang/chart/.craft +++ /dev/null @@ -1,2 +0,0 @@ -# Helm values overrides configuration ---- diff --git a/testdata/run/golang/chart/.helmignore b/testdata/run/golang/chart/.helmignore deleted file mode 100644 index d5eeda75..00000000 --- a/testdata/run/golang/chart/.helmignore +++ /dev/null @@ -1,28 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store - -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ - -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ - -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ \ No newline at end of file diff --git a/testdata/run/golang/chart/Chart.yaml b/testdata/run/golang/chart/Chart.yaml deleted file mode 100644 index 913821a2..00000000 --- a/testdata/run/golang/chart/Chart.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -apiVersion: v2 -name: craft -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "0.1.0" - -dependencies: [] - -maintainers: - - name: maintainer name diff --git a/testdata/run/golang/chart/charts/.gitkeep b/testdata/run/golang/chart/charts/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/testdata/run/golang/chart/templates/_helpers.tpl b/testdata/run/golang/chart/templates/_helpers.tpl deleted file mode 100644 index 1661bfe7..00000000 --- a/testdata/run/golang/chart/templates/_helpers.tpl +++ /dev/null @@ -1,64 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{/* -Expand the name of the chart. -*/}} -{{- define "craft.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "craft.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "craft.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "craft.labels" -}} -helm.sh/chart: {{ include "craft.chart" . }} -{{ include "craft.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "craft.selectorLabels" -}} -app.kubernetes.io/name: {{ include "craft.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "craft.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "craft.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/testdata/run/golang/chart/templates/configmap.yaml b/testdata/run/golang/chart/templates/configmap.yaml deleted file mode 100644 index d334cbbb..00000000 --- a/testdata/run/golang/chart/templates/configmap.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} - -{{ range $name, $config := merge .Values.crons .Values.jobs .Values.workers }} -{{ with $config.configMap }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ print $fullname "-" $name }} -data: -{{- range .tpl_folders }} -{{- range $path, $_ := $.Files.Glob (print . "/**") }} - {{ base $path }}: |- - {{ tpl ($.Files.Get $path) . }} -{{- end }} -{{- end }} - -{{- range .include_folders }} -{{- range $path, $_ := $.Files.Glob (print . "/**") }} - {{ base $path }}: |- - {{ $.Files.Get $path }} -{{- end }} -{{- end }} - -{{- if .data }} - {{- toYaml (tpl .data .) | nindent 2 }} -{{- end }} -{{ end }} -{{ end }} \ No newline at end of file diff --git a/testdata/run/golang/chart/templates/cronjob.yaml b/testdata/run/golang/chart/templates/cronjob.yaml deleted file mode 100644 index ee146003..00000000 --- a/testdata/run/golang/chart/templates/cronjob.yaml +++ /dev/null @@ -1,104 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.crons }} -apiVersion: batch/v1beta1 -kind: CronJob -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - suspend: {{ $config.suspend }} - schedule: {{ $config.schedule | quote }} - concurrencyPolicy: {{ $config.concurrencyPolicy }} - failedJobsHistoryLimit: {{ $config.failedJobsHistoryLimit }} - successfulJobsHistoryLimit: {{ $config.successfulJobsHistoryLimit }} - jobTemplate: - spec: - completionMode: {{ $config.completionMode }} - completions: {{ $config.completions }} - parallelism: {{ $config.parallelism }} - selector: - matchLabels: - {{- $selectorLabels | nindent 10 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 12 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 12 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 12 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 12 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 16 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 16 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 16 }} - {{- end }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 16 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 12 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/run/golang/chart/templates/deployment.yaml b/testdata/run/golang/chart/templates/deployment.yaml deleted file mode 100644 index ce640a6a..00000000 --- a/testdata/run/golang/chart/templates/deployment.yaml +++ /dev/null @@ -1,114 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.workers }} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - paused: {{ $config.paused }} - {{- if not $config.autoscaling.enabled }} - replicas: {{ $config.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- $selectorLabels | nindent 6 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 8 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 8 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 12 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - ports: - - name: http - containerPort: {{ $config.service.port }} - protocol: TCP - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - {{- with $config.livenessProbe }} - livenessProbe: - {{- toYaml $config.livenessProbe | nindent 12 }} - {{- end }} - {{- with $config.readinessProbe }} - readinessProbe: - {{- toYaml $config.readinessProbe | nindent 12 }} - {{- end }} - {{- with $config.startupProbe }} - startupProbe: - {{- toYaml $config.startupProbe | nindent 12 }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 12 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/run/golang/chart/templates/hpa.yaml b/testdata/run/golang/chart/templates/hpa.yaml deleted file mode 100644 index c6c8d9a6..00000000 --- a/testdata/run/golang/chart/templates/hpa.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} - -{{ range $name, $config := .Values.workers }} -{{- if $config.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ print $fullname "-" $name }} - minReplicas: {{ $config.autoscaling.minReplicas }} - maxReplicas: {{ $config.autoscaling.maxReplicas }} - metrics: - {{- toYaml $config.autoscaling.metrics | nindent 4 }} -{{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/run/golang/chart/templates/job.yaml b/testdata/run/golang/chart/templates/job.yaml deleted file mode 100644 index b476f534..00000000 --- a/testdata/run/golang/chart/templates/job.yaml +++ /dev/null @@ -1,102 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} - -{{ range $name, $config := .Values.jobs }} -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ print $fullname "-" $name }} - namespace: default - labels: - {{- $labels | nindent 4 }} -spec: - suspend: {{ $config.suspend }} - completionMode: {{ $config.completionMode }} - completions: {{ $config.completions }} - parallelism: {{ $config.parallelism }} - {{- with $config.ttlSecondsAfterFinished }} - ttlSecondsAfterFinished: {{ . }} - {{- end }} - selector: - matchLabels: - {{- $selectorLabels | nindent 6 }} - template: - metadata: - {{- with $config.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- $selectorLabels | nindent 8 }} - spec: - {{- with $.Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ $serviceAccountName }} - securityContext: - {{- toYaml $config.podSecurityContext | nindent 8 }} - containers: - - name: {{ $name }} - securityContext: - {{- toYaml $config.securityContext | nindent 12 }} - {{- if $config.image.registry }} - image: "{{ $config.image.registry }}/{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- else }} - image: "{{ $config.image.repository }}:{{ $config.image.tag | default $.Chart.AppVersion }}" - {{- end }} - {{- with $config.image.pullPolicy }} - imagePullPolicy: {{ . }} - {{- end }} - {{- with $config.env }} - env: - {{- range $name, $value := . }} - - name: {{ $name }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- with $config.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if or $config.configMap $config.volumeMounts }} - volumeMounts: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - mountPath: {{ .mountPath }} - {{- end }} - {{- with $config.volumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- end }} - resources: - {{- toYaml $config.resources | nindent 12 }} - restartPolicy: {{ $config.restartPolicy }} - {{- if or $config.configMap $config.volumes }} - volumes: - {{- with $config.configMap }} - - name: {{ print $fullname "-" $name }} - configMap: - name: {{ print $fullname "-" $name }} - {{- end }} - {{- with $config.volumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- with $config.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $config.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{ end }} \ No newline at end of file diff --git a/testdata/run/golang/chart/templates/service.yaml b/testdata/run/golang/chart/templates/service.yaml deleted file mode 100644 index 61dfa73d..00000000 --- a/testdata/run/golang/chart/templates/service.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $fullname := include (print .Chart.Name ".fullname") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} -{{- $selectorLabels := include (print .Chart.Name ".selectorLabels") . -}} - -{{ range $name, $config := .Values.workers }} -apiVersion: v1 -kind: Service -metadata: - name: {{ print $fullname "-" $name }} - labels: - {{- $labels | nindent 4 }} -spec: - type: ClusterIP - ports: - - port: {{ $config.env.BINARY_PORT | default 3000 }} - targetPort: http - protocol: TCP - name: http - selector: - {{- $selectorLabels | nindent 4 }} -{{ end }} \ No newline at end of file diff --git a/testdata/run/golang/chart/templates/serviceaccount.yaml b/testdata/run/golang/chart/templates/serviceaccount.yaml deleted file mode 100644 index e0f0a202..00000000 --- a/testdata/run/golang/chart/templates/serviceaccount.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -{{- $serviceAccountName := include (print .Chart.Name ".serviceAccountName") . -}} -{{- $labels := include (print .Chart.Name ".labels") . -}} - -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ $serviceAccountName }} - labels: - {{- $labels | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/testdata/run/golang/chart/values.yaml b/testdata/run/golang/chart/values.yaml deleted file mode 100644 index c34b786d..00000000 --- a/testdata/run/golang/chart/values.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -imagePullSecrets: [] - -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: false - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -############################################# -# all cronjobs # -############################################# -crons: {} - -############################################# -# all jobs # -############################################# -jobs: {} - -############################################# -# all workers # -############################################# -workers: {} - -############################################# -# all dependencies # -############################################# \ No newline at end of file diff --git a/testdata/run/golang/go.mod b/testdata/run/golang/go.mod deleted file mode 100644 index 9527cda1..00000000 --- a/testdata/run/golang/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/kilianpaquier/craft - -go 1.22.0 - -toolchain go1.22.2 \ No newline at end of file diff --git a/testdata/run/golang/scripts/build.mk b/testdata/run/golang/scripts/build.mk deleted file mode 100644 index 273e333c..00000000 --- a/testdata/run/golang/scripts/build.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -GCI_CONFIG_PATH := .golangci.yml - -.PHONY: reports -reports: - @mkdir -p reports/ - -.PHONY: lint -lint: reports - @golangci-lint run -c ${GCI_CONFIG_PATH} --timeout 240s --fast --sort-results \ - --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number $(ARGS) || \ - echo "golangci-lint failed, running 'make lint-fix' may fix some issues" - -.PHONY: lint-fix -lint-fix: reports - @ARGS="--fix" make -s lint - -.PHONY: test -test: - @go test ./... -count 1 -timeout=15s - -.PHONY: test-race -test-race: - @CGO_ENABLED=1 go test ./... -race -timeout=15s - -.PHONY: test-cover -test-cover: reports - @go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s \ No newline at end of file diff --git a/testdata/run/golang/scripts/craft.mk b/testdata/run/golang/scripts/craft.mk deleted file mode 100644 index 16d51b9e..00000000 --- a/testdata/run/golang/scripts/craft.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: generate -generate: - @craft generate $(ARGS) - -.PHONY: clean -clean: - @go clean - @git clean -Xf ./* \ No newline at end of file diff --git a/testdata/run/golang/scripts/install.mk b/testdata/run/golang/scripts/install.mk deleted file mode 100644 index 3438dfbb..00000000 --- a/testdata/run/golang/scripts/install.mk +++ /dev/null @@ -1,24 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -.PHONY: install-golangci-lint -install-golangci-lint: - @curl -fsSL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b "${HOME}/go/bin" - -define install_go -current_version=$(go version || echo "go0.0.0") -new_version=$(curl -fsSL "https://go.dev/dl/?mode=json" | jq -r '.[0].version') -if echo "${current_version}" | grep -Eq "${new_version}"; then - echo "latest go version ${new_version} already installed" - exit 0 -fi - -echo "installing latest go version ${new_version}" -rm -rf "${HOME}/.local/go" && mkdir -p "${HOME}/.local/go" -curl -fsSL "https://go.dev/dl/${new_version}.linux-amd64.tar.gz" | (cd "${HOME}/.local/go" && tar -xz --strip-components=1) -for item in "go" "gofmt"; do - chmod +x "${HOME}/.local/go/bin/${item}" && ln -sf "${HOME}/.local/go/bin/${item}" "${HOME}/.local/bin/${item}" -done -endef -.PHONY: install-go -install-go: ; @$(value install_go) -.ONESHELL: \ No newline at end of file diff --git a/testdata/run/hugo/.github/release.yml b/testdata/run/hugo/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/run/hugo/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/run/hugo/.gitignore b/testdata/run/hugo/.gitignore deleted file mode 100644 index 7ea3eae6..00000000 --- a/testdata/run/hugo/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Generated files by hugo -/assets/jsconfig.json -/dist/ -/public/ -/resources/_gen/ -hugo_stats.json - -# Executable may be added to repository -hugo.exe -hugo.darwin -hugo.linux - -# Temporary lock file while building -/.hugo_build.lock \ No newline at end of file diff --git a/testdata/run/hugo/README.md b/testdata/run/hugo/README.md deleted file mode 100644 index fb193ca7..00000000 --- a/testdata/run/hugo/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues - Go Version -

- ---- \ No newline at end of file diff --git a/testdata/run/hugo/go.mod b/testdata/run/hugo/go.mod deleted file mode 100644 index 9527cda1..00000000 --- a/testdata/run/hugo/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/kilianpaquier/craft - -go 1.22.0 - -toolchain go1.22.2 \ No newline at end of file diff --git a/testdata/run/hugo/hugo.toml b/testdata/run/hugo/hugo.toml deleted file mode 100644 index e69de29b..00000000 diff --git a/testdata/run/nodejs/.github/release.yml b/testdata/run/nodejs/.github/release.yml deleted file mode 100644 index e8fd67e1..00000000 --- a/testdata/run/nodejs/.github/release.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes - -changelog: - categories: - - title: Breaking Changes - labels: - - breaking - - title: Features - labels: - - enhancement - - title: Bug Fixes - labels: - - bug - - title: Documentation - labels: - - documentation - - title: Chores - labels: - - chore - - dependencies - - github_actions \ No newline at end of file diff --git a/testdata/run/nodejs/.gitignore b/testdata/run/nodejs/.gitignore deleted file mode 100644 index ef7f4401..00000000 --- a/testdata/run/nodejs/.gitignore +++ /dev/null @@ -1,133 +0,0 @@ -# Code generated by craft; DO NOT EDIT. - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov -reports - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file diff --git a/testdata/run/nodejs/README.md b/testdata/run/nodejs/README.md deleted file mode 100644 index fed7313e..00000000 --- a/testdata/run/nodejs/README.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# craft - -

- GitHub Release - GitHub Issues -

- ---- \ No newline at end of file diff --git a/testdata/run/nodejs/package.json b/testdata/run/nodejs/package.json deleted file mode 100644 index cf9815d6..00000000 --- a/testdata/run/nodejs/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "description": "", - "name": "craft", - "packageManager": "bun@1.1.6", - "version": "1.0.0", - "repository": { - "url": "https://github.com/kilianpaquier/craft" - } -} \ No newline at end of file diff --git a/testdata/run/templates/invalid/README.md.tmpl b/testdata/run/templates/invalid/README.md.tmpl deleted file mode 100644 index 073c2de2..00000000 --- a/testdata/run/templates/invalid/README.md.tmpl +++ /dev/null @@ -1 +0,0 @@ -# {{ invalid function called }} \ No newline at end of file diff --git a/testdata/run/templates/valid/NOT_GENERATED.md b/testdata/run/templates/valid/NOT_GENERATED.md deleted file mode 100644 index 35078271..00000000 --- a/testdata/run/templates/valid/NOT_GENERATED.md +++ /dev/null @@ -1 +0,0 @@ -SHOULD NOT BE GENERATED SINCE THERE'S NO .TMPL EXTENSION \ No newline at end of file diff --git a/testdata/run/templates/valid/README.md.tmpl b/testdata/run/templates/valid/README.md.tmpl deleted file mode 100644 index 34c11378..00000000 --- a/testdata/run/templates/valid/README.md.tmpl +++ /dev/null @@ -1 +0,0 @@ -# {{ .ProjectName }} \ No newline at end of file