diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 378ec63..4b3104f 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -17,9 +17,6 @@ on: - 'templates/**' - 'tests/**' -env: - GH_ROLE_ARN: arn:aws:iam::602046956384:role/GithubActions-github-actions-services-repos-Role - jobs: build-and-test: name: Build and Test @@ -29,34 +26,13 @@ jobs: contents: read actions: read steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::602046956384:role/GithubActions-github-actions-services-repos-Role - aws-region: 'us-east-1' - - name: Get Github Secrets from Secrets manager - uses: aws-actions/aws-secretsmanager-get-secrets@v2 - with: - secret-ids: | - GITHUB_CUE_APP_KEY ## <> ## <> - - name: Generate a token - id: generate_token - uses: actions/create-github-app-token@v1 - with: - app-id: 407179 - private-key: ${{ env.GITHUB_CUE_APP_KEY }} - owner: udemy - - name: Set git Credentials - run: | - git config --global "url.https://udemy:${{ steps.generate_token.outputs.token }}@github.com/.insteadOf" https://github.com/ - name: Checkout uses: actions/checkout@v4 with: persist-credentials: false - token: ${{ steps.generate_token.outputs.token }} # These two required for builds to successfully amend commits ref: ${{ github.head_ref }} fetch-depth: 2 @@ -76,18 +52,16 @@ jobs: ## <> - name: Build Test repo run: mise run buildtest - env: - GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} - ## <> + # Fill in env: -> GITHUB_TOKEN here if you need a custom token to read module dependencies + ## <> - ## <> + ## <> - name: Run Tests run: mise run runtest - env: - GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} - ## <> - - ## <> + # Fill in env: -> GITHUB_TOKEN here if you need a custom token to read module dependencies + ## <> + + ## <> ## <> ## <> diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..ad05a18 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2024 Udemy, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index b6f18c8..6890d8d 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ In the `arguments` section of the `manifest.yaml` file, you can specify the foll | Option | Default | Description | | -------------------- | --------------- | ------------------------------------------------------------------------------ | -| `description` | Required | Friendly-but-short description string for the frontend app | -| `owner` | Required | Pod or Portfolio ID for the owner of the frontend app | | `nativeModule` | `false` | Does this module include native module golang code | | `templateModule` | `false` | Does this module include templated code | +| `githubOrg` | Required | The github organization to use for the module | +| `githubOwner` | nil | The github owner to use for the module | | `buildAndTestRunner` | `ubuntu-latest` | The github actions runner to use for the build and test CI job | | `packageJsonDeps` | `{}` | package.json dependencies to add to the generated package.json (key/value map) | | `packageJsonScripts` | `{}` | package.json scripts to add to the generated package.json (key/value map) | diff --git a/manifest.yaml b/manifest.yaml index 11c683b..38732ac 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -1,25 +1,6 @@ name: github.com/udemy/stencil-module-base type: templates -dirReplacements: - ## <> - - ## <> -postRunCommand: - ## <> - - name: yarn install - command: yarn install - ## <> arguments: - description: - required: true - description: Friendly-but-short description string for the repository - schema: - type: string - owner: - required: true - description: Team ID (see eng-team-management repo) for the owner of the repository - schema: - type: string ## <> nativeModule: required: false @@ -31,6 +12,16 @@ arguments: description: Does this module include templated code schema: type: boolean + githubOrg: + required: true + description: The github org of the repository (i.e. github.com/udemy/stencil-module-base -> "udemy") + schema: + type: string + githubOwner: + required: false + description: The github owner of the repository (i.e. @udemy/platform) + schema: + type: string buildAndTestRunner: required: false description: The github actions runner to use for the build and test CI job @@ -44,10 +35,11 @@ arguments: description: package.json scripts to add to the generated package.json (key/value map) ## <> modules: - - name: github.com/udemy/eng-team-management ## <> ## <> ## <> - +postRunCommand: + - name: yarn install + command: yarn install ## <> diff --git a/stencil.yaml b/stencil.yaml index 7402b13..d46119a 100644 --- a/stencil.yaml +++ b/stencil.yaml @@ -1,9 +1,9 @@ # yaml-language-server: $schema=https://stencil.rgst.io/static/stencil.jsonschema.json name: stencil-module-base arguments: - description: Stencil module forming the base for stencil template modules - owner: platform templateModule: true + githubOrg: udemy + githubOwner: "@udemy/platform" modules: - name: github.com/udemy/stencil-module-base replacements: diff --git a/templates/.github/CODEOWNERS.tpl b/templates/.github/CODEOWNERS.tpl index a9648da..6e26156 100644 --- a/templates/.github/CODEOWNERS.tpl +++ b/templates/.github/CODEOWNERS.tpl @@ -1,4 +1,6 @@ +{{- if not (stencil.Arg "githubOwner") -}} +{{- file.Delete -}} +{{- end -}} # See https://help.github.com/articles/about-codeowners/ # Default ownership -- owning team owns everything by default -{{- $teamInfo := stencil.GetGlobal "TeamInfo" | default (dict) }} -* @udemy/{{ index $teamInfo "githubTeam" }} +* {{ stencil.Arg "githubOwner" }} diff --git a/templates/.github/workflows/build-release.yml.tpl b/templates/.github/workflows/build-release.yml.tpl index afb17c9..95e3665 100644 --- a/templates/.github/workflows/build-release.yml.tpl +++ b/templates/.github/workflows/build-release.yml.tpl @@ -27,9 +27,6 @@ on: - 'internal/**' {{- end }} -env: - GH_ROLE_ARN: arn:aws:iam::602046956384:role/GithubActions-github-actions-services-repos-Role - jobs: build-and-test: name: Build and Test @@ -39,34 +36,13 @@ jobs: contents: read actions: read steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::602046956384:role/GithubActions-github-actions-services-repos-Role - aws-region: 'us-east-1' - - name: Get Github Secrets from Secrets manager - uses: aws-actions/aws-secretsmanager-get-secrets@v2 - with: - secret-ids: | - GITHUB_CUE_APP_KEY ## <> {{ file.Block "getMoreCiSecrets" }} ## <> - - name: Generate a token - id: generate_token - uses: actions/create-github-app-token@v1 - with: - app-id: 407179 - private-key: {{ "${{ env.GITHUB_CUE_APP_KEY }}" }} - owner: udemy - - name: Set git Credentials - run: | - git config --global "url.https://udemy:{{ "${{ steps.generate_token.outputs.token }}" }}@github.com/.insteadOf" https://github.com/ - name: Checkout uses: actions/checkout@v4 with: persist-credentials: false - token: {{ "${{ steps.generate_token.outputs.token }}" }} # These two required for builds to successfully amend commits ref: {{ "${{ github.head_ref }}" }} fetch-depth: 2 @@ -76,11 +52,6 @@ jobs: experimental: true env: GH_TOKEN: {{ "${{ secrets.GITHUB_TOKEN }}" }} - - name: Install Stencil - uses: rgst-io/stencil-action@34abb7be7ca3847f233bd9c38f1da71b30556c35 - with: - github-token: {{ "${{ github.token }}" }} - version: 'latest' {{- if stencil.Arg "nativeModule" }} - name: Get Go directories id: go @@ -112,23 +83,26 @@ jobs: ## <> {{- end }} {{- if stencil.Arg "templateModule" }} + - name: Install Stencil + uses: rgst-io/stencil-action@34abb7be7ca3847f233bd9c38f1da71b30556c35 + with: + github-token: {{ "${{ github.token }}" }} + version: 'latest' ## <> {{ file.Block "buildtestauth" }} ## <> - name: Build Test repo run: mise run buildtest - env: - GITHUB_TOKEN: {{ "${{ steps.generate_token.outputs.token }}" }} - ## <> + # Fill in env: -> GITHUB_TOKEN here if you need a custom token to read module dependencies + ## <> {{ file.Block "buildTestEnvVars" }} - ## <> + ## <> - name: Run Tests run: mise run runtest - env: - GITHUB_TOKEN: {{ "${{ steps.generate_token.outputs.token }}" }} - ## <> + # Fill in env: -> GITHUB_TOKEN here if you need a custom token to read module dependencies + ## <> {{ file.Block "runTestEnvVars" }} - ## <> + ## <> ## <> {{ file.Block "arguments" }} ## <> diff --git a/templates/.goreleaser.yaml.tpl b/templates/.goreleaser.yaml.tpl index 48393d7..cdd681e 100644 --- a/templates/.goreleaser.yaml.tpl +++ b/templates/.goreleaser.yaml.tpl @@ -45,4 +45,4 @@ changelog: release: prerelease: "auto" footer: |- - {{ "**Full Changelog**: https://github.com/udemy/eng-team-management/compare/{{ .PreviousTag }}...{{ .Tag }}" }} + **Full Changelog**: https://github.com/{{ stencil.Arg "githubOrg" }}/{{ .Config.Name }}/compare/{{ "{{ .PreviousTag }}...{{ .Tag }}" }} diff --git a/templates/go.mod.tpl b/templates/go.mod.tpl index 0fd481e..2f8b7f2 100644 --- a/templates/go.mod.tpl +++ b/templates/go.mod.tpl @@ -1,7 +1,7 @@ {{- if not (stencil.Arg "nativeModule") -}} {{- file.Delete -}} {{- end -}} -module github.com/udemy/{{ .Config.Name }} +module github.com/{{ stencil.Arg "githubOrg" }}/{{ .Config.Name }} go 1.23.1 diff --git a/templates/manifest.yaml.tpl b/templates/manifest.yaml.tpl index 5aac259..b722fbc 100644 --- a/templates/manifest.yaml.tpl +++ b/templates/manifest.yaml.tpl @@ -1,4 +1,4 @@ -name: github.com/udemy/{{ .Config.Name }} +name: github.com/{{ stencil.Arg "githubOrg" }}/{{ .Config.Name }} {{- if and (stencil.Arg "nativeModule") (stencil.Arg "templateModule") }} type: templates,extension {{- else if stencil.Arg "nativeModule" }} @@ -8,30 +8,11 @@ type: templates {{- else }} {{- fail "Either templateModule or nativeModule must be true" }} {{- end }} -dirReplacements: - ## <> -{{ file.Block "dirReplacements" }} - ## <> -postRunCommand: - ## <> -{{ file.Block "postruncommands" }} - ## <> arguments: - description: - required: true - description: Friendly-but-short description string for the repository - schema: - type: string - owner: - required: true - description: Team ID (see eng-team-management repo) for the owner of the repository - schema: - type: string ## <> {{ file.Block "arguments" }} ## <> modules: - - name: github.com/udemy/eng-team-management ## <> {{ file.Block "modules" }} ## <> diff --git a/templates/templates.library.tpl b/templates/templates.library.tpl deleted file mode 100644 index c02ca99..0000000 --- a/templates/templates.library.tpl +++ /dev/null @@ -1,3 +0,0 @@ -# This will blow up inside the native extension if the team isn't found -{{ $teamInfo := extensions.Call "github.com/udemy/eng-team-management.GetTeamByID" (stencil.Arg "owner") }} -{{ stencil.SetGlobal "TeamInfo" $teamInfo }} diff --git a/templates/tests/basic/stencil.yaml.tpl b/templates/tests/basic/stencil.yaml.tpl index a6fcfac..78afa44 100644 --- a/templates/tests/basic/stencil.yaml.tpl +++ b/templates/tests/basic/stencil.yaml.tpl @@ -6,10 +6,8 @@ # yaml-language-server: $schema=https://stencil.rgst.io/static/stencil.jsonschema.json name: {{ .Config.Name }}-test arguments: - description: Test folder for validating changes to {{ .Config.Name }} - owner: {{ stencil.Arg "owner"}} templateModule: true modules: - - name: github.com/udemy/{{ .Config.Name }} + - name: github.com/{{ stencil.Arg "githubOrg" }}/{{ .Config.Name }} replacements: - github.com/udemy/{{ .Config.Name }}: ../../ + github.com/{{ stencil.Arg "githubOrg" }}/{{ .Config.Name }}: ../../ diff --git a/tests/both/stencil.yaml b/tests/both/stencil.yaml index 7c4245e..eb1c24a 100644 --- a/tests/both/stencil.yaml +++ b/tests/both/stencil.yaml @@ -1,10 +1,10 @@ # yaml-language-server: $schema=https://stencil.rgst.io/static/stencil.jsonschema.json name: stencil-module-base-test-both arguments: - description: Test native+template project for validating changes to stencil-module-base - owner: platform templateModule: true nativeModule: true + githubOrg: udemy + githubOwner: "@udemy/platform" modules: - name: github.com/udemy/stencil-module-base replacements: diff --git a/tests/native/stencil.yaml b/tests/native/stencil.yaml index 9a76ab4..3f03034 100644 --- a/tests/native/stencil.yaml +++ b/tests/native/stencil.yaml @@ -1,9 +1,9 @@ # yaml-language-server: $schema=https://stencil.rgst.io/static/stencil.jsonschema.json name: stencil-module-base-test-native arguments: - description: Test native module for validating changes to stencil-module-base - owner: platform nativeModule: true + githubOrg: udemy + githubOwner: "@udemy/platform" modules: - name: github.com/udemy/stencil-module-base replacements: diff --git a/tests/template/stencil.yaml b/tests/template/stencil.yaml index 3f0ea88..11ed3f4 100644 --- a/tests/template/stencil.yaml +++ b/tests/template/stencil.yaml @@ -1,9 +1,9 @@ # yaml-language-server: $schema=https://stencil.rgst.io/static/stencil.jsonschema.json name: stencil-module-base-test-template arguments: - description: Test template module for validating changes to stencil-module-base - owner: platform templateModule: true + githubOrg: udemy + githubOwner: "@udemy/platform" packageJsonScripts: build: echo "build" test: echo "test"