Skip to content

Commit

Permalink
feat: Initial version of Home Run (#1)
Browse files Browse the repository at this point in the history
This PR implements the initial version of Home Run. The original version
lived in multiple Investec Azure DevOps repos.
## How is this put together?

We've used [Create TypeScript App
](https://github.com/JoshuaKGoldberg/create-typescript-app) to scaffold
out a respository. CTA is designed to scaffold TypeScript apps in
GitHub. I should probably mention that I'm a contributor to that
project. It's very useful.

As a consequence, this repo includes GitHub workflows that cover the
following:
- building
- linting
- formatting
- testing
- publishing (using CI/CD and semantic releases)

## Copyright

As per [our
documentation](https://oneinvestec.atlassian.net/wiki/spaces/ICEX/pages/219962846/License+and+Copyright),
our codefiles feature a header that asserts Investec's Copyright:

```ts
/**
 * Copyright (c) Investec
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 */
```

## Contribution guide

As per [our
documentation](https://oneinvestec.atlassian.net/wiki/spaces/ICEX/pages/220036857/How+to+get+started+contributing),
the repository features a [guide on how to
contribute](https://github.com/investec/home-run/blob/prepare/.github/CONTRIBUTING.md).
This includes a code of conduct and a guide on how to get up and running
with development.

## Still to do

At the time of writing, this is a **private** repository on GitHub. It
will remain so until we feel ready to hit the "Public" button. Before
that we will share with Architecture and Engineering Steercom. The
document that will be shared with Architecture and Engineering Steerco
proposing the OSSing of Home Run can be [found
here](https://investeceu-my.sharepoint.com/:w:/g/personal/john_reilly_investec_com/Eds8CqWM1nRHiibDZ3os2tUBlL3PSdKt4kjVba8coDi6Sw?e=333TAn).

### Scanning

One the repo is public (has been open sourced) then we can start to plug
in workflows such as GitHub Advanced Security that will handle
dependency upgrades etc. We need our repo to be public in order to be
able to use them.

However, with the help of @irfanj01, @rick-roche and @ctaceygreen, we
have tested this repo in Azure DevOps using GitHub Advanced Security for
Azure DevOps and found a clean bill of health:


https://dev.azure.com/investec/sandbox/_build/results?buildId=1164607&view=logs&j=70764e4f-eaf2-5618-fd0d-39e528c90335&t=92265a00-6845-5c35-4128-4c776c06c827

<img width="1139" alt="screenshot of clean bill of health"
src="https://github.com/user-attachments/assets/2223b848-2eef-440f-836a-1c5bdce69f2c">

### Publishing to npm

We have not configured publishing to npm. We will do this with the help
of @marktew once we have approval from A&E SteerCo.

### General tidy

There are references in the
[`DEVELOPMENT.md`](https://github.com/investec/home-run/blob/prepare/.github/DEVELOPMENT.md)
to Investec specific projects. These will replaced with something more
generic prior to OSSing. They are useful now for demo purposes. Possibly
some other bits and pieces.

We will look to do this before merging this PR. We aim not to merge this
PR until A&E SteerCo have approved.

### More tests!

We have automated tests in place, we had none on the original codebase.
We should increase the coverage further and we will.

## The Home Run codebase

The Home Run codebase was taken from an internal repository in
Investec's Azure DevOps

As it has been moved into the new codebase, we have enhanced it to make
use of some nice affordances taken from CTA such as spinners /
formatters etc.

Rather than repeat the docs for Home Run in this PR, it's worth reading
the
[README.md](https://github.com/investec/home-run/blob/prepare/README.md).
  • Loading branch information
johnnyreilly authored Nov 19, 2024
1 parent b71f0aa commit a371a50
Show file tree
Hide file tree
Showing 52 changed files with 2,938 additions and 517 deletions.
15 changes: 0 additions & 15 deletions .all-contributorsrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
john.reilly@investec.com.
`john.reilly@investec.com`.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
6 changes: 1 addition & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ Once you've addressed all our feedback by making code changes and/or started a f

Once all feedback is addressed and the PR is approved, we'll ensure the branch is up to date with `main` and merge it for you.

#### Post-Merge Recognition

Once your PR is merged, if you haven't yet been added to the [_Contributors_ table in the README.md](../README.md#contributors) for its [type of contribution](https://allcontributors.org/docs/en/emoji-key "Allcontributors emoji key"), you should be soon.
Please do ping the maintainer who merged your PR if that doesn't happen within 24 hours - it was likely an oversight on our end!

## Emojis & Appreciation

If you made it all the way to the end, bravo dear user, we love you.
Please include your favorite emoji in the bottom of your issues and PRs to signal to us that you did in fact read this file and are trying to conform to it as best as possible.

💖 is a good starter if you're not sure which to use.
33 changes: 33 additions & 0 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Development

To develop this project, you need to have the following tools installed:

- [Node.js](https://nodejs.org/) (and npm)
- [pnpm](https://pnpm.io/)
- [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/)

After [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo) and [installing pnpm](https://pnpm.io/installation):

```shell
Expand All @@ -11,6 +17,33 @@ pnpm install
> This repository includes a list of suggested VS Code extensions.
> It's a good idea to use [VS Code](https://code.visualstudio.com) and accept its suggestion to install them, as they'll help with development.
## Running locally

To test `npx` mode locally, run:

```sh
pnpm run build
az login
```

### `explicit` - specify Azure resources explicitly

You can test the `explicit` mode by running:

```sh
npx . --mode explicit --subscriptionName our-subscription --resourceGroupName rg-our-resource-group --type containerapp --name ca-ourapp-dev --keyVaultName kv-ourapp-dev --appLocation [PATH TO YOUR CONTAINER APP]
```

The above two examples will configure the local development environment for the `OurContainerApp` respectively. I'll replace the above examples with something more generic in future.

### `resourcegroup` - one app per resource group with git branch tags

If you're using the `resourcegroup` mode, then there's an implicit expectation that you'll be executing the command from within the directory of the app you're interested in configuring. For example, if you're in the `OurContainerApp` directory, you can run:

```sh
npx [PATH TO HOME RUN] --mode resourcegroup --subscriptionName our-subscription --resourceGroupName rg-our-resource-group --type containerapp --appLocation ./src/OurContainerApp
```

## Building

Run [**tsup**](https://tsup.egoist.dev) locally to build source files from `src/` into output files in `lib/`:
Expand Down
16 changes: 8 additions & 8 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"automerge": true,
"extends": ["config:best-practices", "replacements:all"],
"ignoreDeps": ["codecov/codecov-action"],
"labels": ["dependencies"],
"minimumReleaseAge": "7 days",
"patch": { "enabled": false },
"postUpdateOptions": ["pnpmDedupe"]
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"automerge": true,
"extends": ["config:best-practices", "replacements:all"],
"ignoreDeps": ["codecov/codecov-action"],
"labels": ["dependencies"],
"minimumReleaseAge": "7 days",
"patch": { "enabled": false },
"postUpdateOptions": ["pnpmDedupe"]
}
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
- uses: ./.github/actions/prepare
- run: pnpm build
- run: node ./lib/index.js

lint:
name: Lint
runs-on: ubuntu-latest
Expand All @@ -15,20 +16,23 @@ jobs:
- uses: ./.github/actions/prepare
- run: pnpm build
- run: pnpm lint

lint_packages:
name: Lint Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm lint:packages

prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm format --list-different

test:
name: Test
runs-on: ubuntu-latest
Expand All @@ -37,6 +41,7 @@ jobs:
- uses: ./.github/actions/prepare
- run: pnpm run test --coverage
- uses: codecov/codecov-action@v3

type_check:
name: Type Check
runs-on: ubuntu-latest
Expand All @@ -45,6 +50,15 @@ jobs:
- uses: ./.github/actions/prepare
- run: pnpm tsc

are_the_types_wrong:
name: Are the types wrong?
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm build
- run: npx --yes @arethetypeswrong/cli --pack . --ignore-rules cjs-resolves-to-esm

name: CI

on:
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.test.*
23 changes: 15 additions & 8 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{
"$schema": "http://json.schemastore.org/prettierrc",
"overrides": [{ "files": ".nvmrc", "options": { "parser": "yaml" } }],
"plugins": [
"prettier-plugin-curly",
"prettier-plugin-sh",
"prettier-plugin-packagejson"
],
"useTabs": true
"$schema": "http://json.schemastore.org/prettierrc",
"overrides": [
{
"files": ".nvmrc",
"options": {
"parser": "yaml"
}
}
],
"plugins": [
"prettier-plugin-curly",
"prettier-plugin-sh",
"prettier-plugin-packagejson"
],
"useTabs": false
}
32 changes: 16 additions & 16 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"git": {
"commitMessage": "chore: release v${version}",
"requireCommits": true
},
"github": {
"autoGenerate": true,
"release": true,
"releaseName": "v${version}"
},
"npm": { "publishArgs": ["--access public", "--provenance"] },
"plugins": {
"@release-it/conventional-changelog": {
"infile": "CHANGELOG.md",
"preset": "angular"
}
}
"git": {
"commitMessage": "chore: release v${version}",
"requireCommits": true
},
"github": {
"autoGenerate": true,
"release": true,
"releaseName": "v${version}"
},
"npm": { "publishArgs": ["--access public", "--provenance"] },
"plugins": {
"@release-it/conventional-changelog": {
"infile": "CHANGELOG.md",
"preset": "angular"
}
}
}
10 changes: 5 additions & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"recommendations": [
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"vitest.explorer"
]
}
44 changes: 22 additions & 22 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"configurations": [
{
"args": ["run", "${relativeFile}"],
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"name": "Debug Current Test File",
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"request": "launch",
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"type": "node"
},
{
"name": "Debug Program",
"preLaunchTask": "build",
"program": "./bin/index.js",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"type": "node"
}
],
"version": "0.2.0"
"configurations": [
{
"args": ["run", "${relativeFile}"],
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"name": "Debug Current Test File",
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"request": "launch",
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"type": "node"
},
{
"name": "Debug Program",
"preLaunchTask": "build",
"program": "./bin/index.js",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"type": "node"
}
],
"version": "0.2.0"
}
33 changes: 16 additions & 17 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.rulers": [80],
"eslint.probe": [
"javascript",
"javascriptreact",
"json",
"jsonc",
"markdown",
"typescript",
"typescriptreact",
"yaml"
],
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"eslint.useFlatConfig": true,
"typescript.tsdk": "node_modules/typescript/lib"
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.probe": [
"javascript",
"javascriptreact",
"json",
"jsonc",
"markdown",
"typescript",
"typescriptreact",
"yaml"
],
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"eslint.useFlatConfig": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
18 changes: 9 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"tasks": [
{
"detail": "Build the project",
"label": "build",
"script": "build",
"type": "npm"
}
],
"version": "2.0.0"
"tasks": [
{
"detail": "Build the project",
"label": "build",
"script": "build",
"type": "npm"
}
],
"version": "2.0.0"
}
2 changes: 2 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# MIT License

Copyright (c) Investec

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
Expand Down
Loading

0 comments on commit a371a50

Please sign in to comment.