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

feat(ci): adds more CI validations, introduces semantic release (#74) #75

Merged
merged 1 commit into from
Apr 22, 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
18 changes: 18 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"scope-enum": [
2,
"always",
[
"certificates",
"network",
"wallet",
"api",
"stargate"
]
]
}
}
13 changes: 11 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true }]
}
"@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true }],
"@typescript-eslint/no-explicit-any": "warn"
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
35 changes: 35 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Setup Node.js and Cache Dependencies'
description: 'Checks out code, sets up Node.js, installs dependencies, and handles caching'

inputs:
node-version:
description: 'Node.js version to setup'
required: true
default: '18.0.0'

runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Restore node_modules cache
id: deps-cache
uses: martijnhols/actions-cache/restore@v3
with:
path: node_modules
key: ${{ runner.os }}-build-ts-deps-cache-${{ hashFiles('ts/package-lock.json') }}

- name: Install dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
shell: bash
run: npm install

- name: Cache node modules
if: steps.deps-cache.outputs.cache-hit != 'true'
uses: martijnhols/actions-cache/save@v3
with:
path: node_modules
key: ${{ runner.os }}-build-ts-deps-cache-${{ hashFiles('ts/package-lock.json') }}
30 changes: 0 additions & 30 deletions .github/workflows/build.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/code-style-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Code Style

on:
- workflow_call

env:
HUSKY: 0

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js and Cache Dependencies
uses: ./.github/actions/setup-node

- name: Lint
run: npm run lint
14 changes: 14 additions & 0 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Code Style

on:
- pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
code-style:
name: Code Style
uses: ./.github/workflows/code-style-reusable.yml
secrets: inherit
19 changes: 19 additions & 0 deletions .github/workflows/commit-lint-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Commit Lint

on:
- workflow_call

env:
HUSKY: 0

jobs:
commit-lint:
name: Validate PR commits with commitlint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate PR commits with commitlint
uses: wagoid/commitlint-github-action@v6

14 changes: 14 additions & 0 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Commit Lint

on:
- pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
commit-lint:
name: Commit Lint
uses: ./.github/workflows/commit-lint-reusable.yml
secrets: inherit
36 changes: 0 additions & 36 deletions .github/workflows/npm.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release from Master on Push

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
HUSKY: 0

jobs:
commit-lint:
name: Commit Lint
uses: ./.github/workflows/commit-lint-reusable.yml
secrets: inherit

lint:
name: Lint and report coverage
uses: ./.github/workflows/code-style-reusable.yml
secrets: inherit

test:
name: Run tests
uses: ./.github/workflows/test-reusable.yml
secrets: inherit

release:
name: Build and release npm package
needs: [commit-lint, lint, test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js and Cache Dependencies
uses: ./.github/actions/setup-node

- name: Release npm package
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

31 changes: 31 additions & 0 deletions .github/workflows/test-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on:
- workflow_call

env:
HUSKY: 0

jobs:
test:
name: Test and report coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js and Cache Dependencies
uses: ./.github/actions/setup-node

- name: Install dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: npm install

- name: Test
run: npm run test:cov

- name: Upload Test Coverage
uses: codecov/codecov-action@v4
with:
files: ./ts/coverage
token: ${{ secrets.CODECOV_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Test

on:
- pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Test
uses: ./.github/workflows/test-reusable.yml
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ umd/

# Coverage directory
.nyc_output/
coverage

# Log files
yarn-error.log
Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit $1
31 changes: 31 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/npm",
{
"tarballDir": "package"
}
],
[
"@semantic-release/github",
{
"assets": "package/*.tgz"
}
],
"@semantic-release/git"
],
"branches": [
{
"name": "main"
}
],
"preset": "conventionalcommits"
}
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@ const signedMessage = await client.signAndBroadcast(

Additional examples can be found in the [examples directory]( https://github.com/ovrclk/akashjs/tree/main/)

## contributing
## Contribution Guidelines

### Project Stack

This repository is primarily written in TypeScript and uses Node.js version 18. We use Webpack 5 for UMD bundling. These tools ensure that our development environment is consistent and our builds are stable.

### Automated CI Checks and Releases

Our project enforces high standards of code quality and consistency to ensure that all contributions adhere to our guidelines and maintain a high level of reliability. Here's what you should be aware of when contributing to our repository:

- **Code Linting**: We use ESLint to analyze the code for potential errors and coding style issues. This ensures that all contributions maintain a consistent style and follow best practices.

- **Code Formatting**: Prettier is configured to format code automatically. This helps keep our codebase clean and readable without requiring manual adjustments for styling.

- **Commit Linting**: All commit messages must adhere to the Conventional Commits specification. This is enforced through automated linting of commits, helping us keep our project history clear and easy to navigate. See [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for more information. [commitizen](https://commitizen-tools.github.io/commitizen/) is a great tool to get started with.

- **Automated Testing**: Upon creating a pull request, automated tests are run to verify that the new code does not break any existing functionality and meets all testing standards.

- **Semantic Release**: When changes are merged into the `main` branch, a semantic release process is triggered. This process automatically determines version numbers and generates changelogs based on the commit messages, streamlining the release process and ensuring consistent versioning.

- **Continuous Integration**: Our CI workflows are designed to validate pull requests and manage releases. They perform multiple checks including commit validation, linting, and testing code coverage before merging changes.

### Contributing

PRs are welcome! By adhering to these guidelines and leveraging our automated systems, we can maintain a high-quality codebase and streamline our development processes. We appreciate your contributions to making this project even better!

This repository uses node 16, and yarn 1.2+, webpack 5 for umd bundling and is written in typescript. PRs are welcome.
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const common = {
};

module.exports = {
collectCoverageFrom: ["./src/**/*.{js,ts}"],
collectCoverageFrom: ["./src/**/*.{js,ts}", "!./src/protobuf/**/*"],
projects: [
{
displayName: "unit",
Expand Down
Loading
Loading