Skip to content

Commit

Permalink
feat: Remove udemy-specific references, readying for open-sourcing (#7)
Browse files Browse the repository at this point in the history
* feat: Moving stencil-module-base to OSS

* tweak

* fix: move to non-empty env blocks in build-release.yml
  • Loading branch information
deregtd authored Oct 3, 2024
1 parent f918ec4 commit 3d74746
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 132 deletions.
40 changes: 7 additions & 33 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
## <<Stencil::Block(getMoreCiSecrets)>>

## <</Stencil::Block>>
- 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
Expand All @@ -76,18 +52,16 @@ jobs:
## <</Stencil::Block>>
- name: Build Test repo
run: mise run buildtest
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
## <<Stencil::Block(buildTestEnvVars)>>
# Fill in env: -> GITHUB_TOKEN here if you need a custom token to read module dependencies
## <<Stencil::Block(buildTestEnvVars)>>

## <</Stencil::Block>>
## <</Stencil::Block>>
- name: Run Tests
run: mise run runtest
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
## <<Stencil::Block(runTestEnvVars)>>

## <</Stencil::Block>>
# Fill in env: -> GITHUB_TOKEN here if you need a custom token to read module dependencies
## <<Stencil::Block(runTestEnvVars)>>

## <</Stencil::Block>>
## <<Stencil::Block(buildteststeps)>>

## <</Stencil::Block>>
Expand Down
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
34 changes: 13 additions & 21 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
name: github.com/udemy/stencil-module-base
type: templates
dirReplacements:
## <<Stencil::Block(dirReplacements)>>

## <</Stencil::Block>>
postRunCommand:
## <<Stencil::Block(postruncommands)>>
- name: yarn install
command: yarn install
## <</Stencil::Block>>
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
## <<Stencil::Block(arguments)>>
nativeModule:
required: false
Expand All @@ -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
Expand All @@ -44,10 +35,11 @@ arguments:
description: package.json scripts to add to the generated package.json (key/value map)
## <</Stencil::Block>>
modules:
- name: github.com/udemy/eng-team-management
## <<Stencil::Block(modules)>>

## <</Stencil::Block>>
## <<Stencil::Block(extra)>>

postRunCommand:
- name: yarn install
command: yarn install
## <</Stencil::Block>>
4 changes: 2 additions & 2 deletions stencil.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
6 changes: 4 additions & 2 deletions templates/.github/CODEOWNERS.tpl
Original file line number Diff line number Diff line change
@@ -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" }}
48 changes: 11 additions & 37 deletions templates/.github/workflows/build-release.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
## <<Stencil::Block(getMoreCiSecrets)>>
{{ file.Block "getMoreCiSecrets" }}
## <</Stencil::Block>>
- 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
Expand All @@ -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
Expand Down Expand Up @@ -112,23 +83,26 @@ jobs:
## <</Stencil::Block>>
{{- end }}
{{- if stencil.Arg "templateModule" }}
- name: Install Stencil
uses: rgst-io/stencil-action@34abb7be7ca3847f233bd9c38f1da71b30556c35
with:
github-token: {{ "${{ github.token }}" }}
version: 'latest'
## <<Stencil::Block(buildtestauth)>>
{{ file.Block "buildtestauth" }}
## <</Stencil::Block>>
- name: Build Test repo
run: mise run buildtest
env:
GITHUB_TOKEN: {{ "${{ steps.generate_token.outputs.token }}" }}
## <<Stencil::Block(buildTestEnvVars)>>
# Fill in env: -> GITHUB_TOKEN here if you need a custom token to read module dependencies
## <<Stencil::Block(buildTestEnvVars)>>
{{ file.Block "buildTestEnvVars" }}
## <</Stencil::Block>>
## <</Stencil::Block>>
- name: Run Tests
run: mise run runtest
env:
GITHUB_TOKEN: {{ "${{ steps.generate_token.outputs.token }}" }}
## <<Stencil::Block(runTestEnvVars)>>
# Fill in env: -> GITHUB_TOKEN here if you need a custom token to read module dependencies
## <<Stencil::Block(runTestEnvVars)>>
{{ file.Block "runTestEnvVars" }}
## <</Stencil::Block>>
## <</Stencil::Block>>
## <<Stencil::Block(buildteststeps)>>
{{ file.Block "arguments" }}
## <</Stencil::Block>>
Expand Down
2 changes: 1 addition & 1 deletion templates/.goreleaser.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}" }}
2 changes: 1 addition & 1 deletion templates/go.mod.tpl
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 1 addition & 20 deletions templates/manifest.yaml.tpl
Original file line number Diff line number Diff line change
@@ -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" }}
Expand All @@ -8,30 +8,11 @@ type: templates
{{- else }}
{{- fail "Either templateModule or nativeModule must be true" }}
{{- end }}
dirReplacements:
## <<Stencil::Block(dirReplacements)>>
{{ file.Block "dirReplacements" }}
## <</Stencil::Block>>
postRunCommand:
## <<Stencil::Block(postruncommands)>>
{{ file.Block "postruncommands" }}
## <</Stencil::Block>>
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
## <<Stencil::Block(arguments)>>
{{ file.Block "arguments" }}
## <</Stencil::Block>>
modules:
- name: github.com/udemy/eng-team-management
## <<Stencil::Block(modules)>>
{{ file.Block "modules" }}
## <</Stencil::Block>>
Expand Down
3 changes: 0 additions & 3 deletions templates/templates.library.tpl

This file was deleted.

6 changes: 2 additions & 4 deletions templates/tests/basic/stencil.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}: ../../
4 changes: 2 additions & 2 deletions tests/both/stencil.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/native/stencil.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/template/stencil.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 3d74746

Please sign in to comment.