Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: scaffolding #1

Merged
merged 16 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
43 changes: 43 additions & 0 deletions .github/actions/use-algokit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Use AlgoKit"

description: "Checks if the dependencies have been cached with the hash of the package-lock.json file."

inputs:
algokit_version:
description: "The version of AlgoKit to install"
required: false
default: "latest"

runs:
using: "composite"
steps:
- name: "πŸ”‘ Set up cache key"
id: cache-key
run: echo "CACHE_KEY=algokit-${{ inputs.algokit_version }}-$(python --version | cut -d' ' -f2)" >> $GITHUB_ENV
shell: bash
- name: "πŸ’Ύ Cache dependencies"
id: algokit-cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ env.CACHE_KEY }}
restore-keys: |
${{ runner.os }}-algokit-${{ inputs.algokit_version }}
${{ runner.os }}-algokit-
${{ runner.os }}-
- name: "πŸ”§ Setup"
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: "πŸ“€ Upgrade pip"
run: python -m pip install --upgrade pip
shell: bash
- name: "πŸ“¦ Install"
if: steps.algokit-cache.outputs.cache-hit != 'true'
run: |
if [ "${{ inputs.algokit_version }}" = "latest" ]; then
pip install algokit # Install the latest version
else
pip install algokit==${{ inputs.algokit_version }}
fi
shell: bash
27 changes: 27 additions & 0 deletions .github/actions/use-npm-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Use npm Dependencies"

description: "Checks if the npm dependencies have been cached with the hash of the package-lock.json file."

runs:
using: "composite"
steps:
- name: "πŸ”§ Setup"
uses: actions/setup-node@v4
with:
node-version: '20.18.0'
- name: "πŸ’Ύ Cache dependencies"
uses: actions/cache@v4
id: npm-cache
with:
path: |
node_modules
~/.cache/Cypress
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
${{ runner.os }}-npm-
${{ runner.os }}-
- name: "πŸ“¦ Install"
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm install
shell: bash
23 changes: 23 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
The title should summarise the purpose of this change.

⚠️**NOTE:** The title must conform to the conventional commit message format outlined in CONTRIBUTING.md document, at the root of the project. This is to ensure the merge commit to the main branch is picked up by the CI and creates an entry in the CHANGELOG.md.
-->

# Description
<!-- Describe your changes in detail -->

# Type of change
<!-- What type of change does this change introduce? Put an 'x' in all the boxes that apply. -->

- [ ] πŸ’₯ Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] πŸ—οΈ Build configuration (CI configuration, scaffolding etc.)
- [ ] πŸ› Bug fix (non-breaking change which fixes an issue)
- [ ] πŸ“ Documentation update(s)
- [ ] πŸ“¦ Dependency update(s)
- [ ] πŸ‘©πŸ½β€πŸ’» Improve developer experience
- [ ] ⚑ Improve performance
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] β™» Refactor
- [ ] βͺ Revert changes
- [ ] πŸ§ͺ New tests or updates to existing tests
126 changes: 126 additions & 0 deletions .github/workflows/pull_request_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: "Pull Request Checks"

on:
pull_request:

jobs:
##
# setup
##

install:
name: "Install"
runs-on: ubuntu-latest
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ”§ Setup"
uses: ./.github/actions/use-npm-dependencies

get_changed_files:
name: "Get Changed Files"
runs-on: ubuntu-latest
outputs:
changed_files: ${{ steps.get_changed_files.outputs.result }}
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ“₯ Get List"
id: get_changed_files
uses: actions/github-script@v7
with:
debug: true
result-encoding: string
script: |
const changedFiles = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
return changedFiles.data.map(f => f.filename).join(',');

##
# validation
##

validate_pr_title:
name: "Validate PR Title"
needs: install
runs-on: ubuntu-latest
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ”§ Setup"
uses: ./.github/actions/use-npm-dependencies
- name: "πŸ“₯ Get PR Title"
id: get_pr_title
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { data } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
return data.title;
- name: "βœ… Validate"
run: echo "${{ steps.get_pr_title.outputs.result }}" | npx commitlint

##
# lint, type check and test
##

check_types_js_client:
name: "Types Check: js-client"
needs: [install, get_changed_files, validate_pr_title]
runs-on: ubuntu-latest
if: contains(needs.get_changed_files.outputs.changed_files, 'packages/js-client/')
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ”§ Setup"
uses: ./.github/actions/use-npm-dependencies
- name: "πŸ” Type Check"
run: npm run check:types --workspace=@kibisis/pinakion-js-client

lint_contract:
name: "Lint: contract"
needs: [install, get_changed_files, validate_pr_title]
runs-on: ubuntu-latest
if: contains(needs.get_changed_files.outputs.changed_files, 'packages/contract/')
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ”§ Setup"
uses: ./.github/actions/use-npm-dependencies
- name: "πŸ‘• Lint"
run: npm run lint:contract

lint_js_client:
name: "Lint: js-client"
needs: [install, get_changed_files, validate_pr_title]
runs-on: ubuntu-latest
if: contains(needs.get_changed_files.outputs.changed_files, 'packages/js-client/')
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ”§ Setup"
uses: ./.github/actions/use-npm-dependencies
- name: "πŸ‘• Lint"
run: npm run lint:js-client

test_js_client:
name: "Test: js-client"
needs: [install, get_changed_files, validate_pr_title]
runs-on: ubuntu-latest
if: contains(needs.get_changed_files.outputs.changed_files, 'packages/js-client/')
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ”§ Setup npm Dependencies"
uses: ./.github/actions/use-npm-dependencies
- name: "πŸ”§ Setup AlgoKit"
uses: ./.github/actions/use-algokit
- name: "πŸ§ͺ Test"
run: npm run test:js-client
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: "Release"

on:
push:
branches:
- beta
- main

permissions:
contents: write # to be able to publish a github release
issues: write # to be able to comment on released issues
packages: write # to be able to publish packages
pull-requests: write # to be able to comment on released pull requests

jobs:
release_contract:
name: "πŸ”– Release - contract"
runs-on: ubuntu-latest
environment: production
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ”§ Setup"
uses: ./.github/actions/use-npm-dependencies
- name: "πŸ”§ Setup AlgoKit"
uses: ./.github/actions/use-algokit
- name: "πŸ—οΈ Build"
run: npm run build:contract
- name: "πŸ”– Release"
env:
HUSKY: 0 # disable husky
# appears on the release commits
GIT_AUTHOR_NAME: kibi-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: kibi-bot
GIT_COMMITTER_EMAIL: [email protected]
# used to push the release commit and create the tags
GITHUB_TOKEN: ${{ secrets.READ_AND_WRITE_REPOS_TOKEN }}
run: npx semantic-release -e semantic-release-monorepo
working-directory: ./packages/contract

release_js_client:
name: "πŸ”– Release - js-client"
runs-on: ubuntu-latest
environment: production
steps:
- name: "πŸ›Ž Checkout"
uses: actions/checkout@v4
- name: "πŸ”§ Setup"
uses: ./.github/actions/use-npm-dependencies
- name: "πŸ”§ Setup AlgoKit"
uses: ./.github/actions/use-algokit
- name: "πŸ“ Create .npmrc"
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISH_PACKAGES_ACCESS_TOKEN }}" >> .npmrc
echo "@kibisis:registry=https://registry.npmjs.org" >> .npmrc
echo "access=public" >> .npmrc
- name: "πŸ—οΈ Build"
run: npm run build:js-client
- name: "πŸ”– Release"
env:
HUSKY: 0 # disable husky
# appears on the release commits
GIT_AUTHOR_NAME: kibi-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: kibi-bot
GIT_COMMITTER_EMAIL: [email protected]
# used to push the release commit and create the tags
GITHUB_TOKEN: ${{ secrets.READ_AND_WRITE_REPOS_TOKEN }}
run: npx semantic-release -e semantic-release-monorepo
working-directory: ./packages/js-client
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx commitlint --edit "$1"
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
'**/*.{js,json,ts}': (filenames) =>
`prettier --write ${filenames.join(' ')}`,
};
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "always",
"endOfLine": "lf",
"printWidth": 120,
"singleQuote": true,
"trailingComma": "es5"
}
Loading
Loading