Skip to content

Commit

Permalink
ci: add initial github actions pipelines
Browse files Browse the repository at this point in the history
added merge request pipeline and manually triggered pipeline trigger, added commitizen support
  • Loading branch information
nathanosdev committed Sep 30, 2022
1 parent b674cec commit c8ecbc1
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .cz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
commitizen:
name: cz_conventional_commits
tag_format: $version
version: 0.0.0
version_files:
- ic-response-verification-rs/Cargo.toml:version
- ic-response-verification-ts/package.json:version
update_changelog_on_bump: true
85 changes: 85 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Pull Request

on:
pull_request:
branches:
- main

jobs:
update_changelog:
name: Update Changelog
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Commitizen
run: |
python -m pip install --upgrade pip
pip install -U Commitizen
- name: Check Commit Messages
run: cz check --rev-range b674cec1368e57e4c73280edfced1db33ea70bb3..HEAD

- name: Update Changelog
run: cz changelog

- name: Commit and Push changes to repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'chore: update changelog'
commit_options: '--no-verify --signoff'
file_pattern: CHANGELOG.md
tagging_message: '${{ steps.cz.outputs.version }}'

build_and_test_rust:
name: Build and Test Rust
runs-on: ubuntu-latest
steps:
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Build
run:
working-directory: ic-response-verification-rs
shell: cargo build --release

- name: Test
run:
working-directory: ic-response-verification-rs
shell: cargo test --lib

- name: Lint
run:
working-directory: ic-response-verification-rs
shell: cargo clippy

- name: Check Formatting
run:
working-directory: ic-response-verification-rs
shell: cargo fmt --all -- --check

build_npm_package:
name: Build NPM Package
runs-on: ubuntu-latest
steps:
- name: Setup Bazel
uses: bazelbuild/setup-bazelisk@v2

- name: Setup Bazel Cache
uses: actions/cache@v3
with:
path: '~/.cache/bazel'
key: bazel

- name: Build
run: bazel build //ic-response-verification-ts:lib
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release

on: workflow_dispatch

jobs:
bump_version:
name: Bump version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- id: cz
name: Run commitizen
uses: commitizen-tools/commitizen-action@master
with:
changelog_increment_filename: RELEASE_NOTES.md
commit: false

- name: Print Version
run: echo "Bumping to version ${{ steps.cz.outputs.version }}"

- name: Update Cargo.lock
run:
working-directory: ic-response-verification-rs
shell: cargo build

- name: Update package-lock.json
run:
working-directory: ic-response-verification-ts
shell: npm i --package-lock-only

- name: Commit and Push changes to repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'bump: release ${{ steps.cz.outputs.version }}'
commit_options: '--no-verify --signoff'
file_pattern: >
.cz.yaml
CHANGELOG.md
ic-response-verification-rs/Cargo.toml
ic-response-verification-rs/Cargo.lock
ic-response-verification-ts/package.json
ic-response-verification-ts/package-lock.json
tagging_message: '${{ steps.cz.outputs.version }}'

- name: Create Cargo crate release
run:
working-directory: ic-response-verification-rs
shell: cargo publish --dry-run

- name: Create NPM package release
run:
working-directory: ic-response-verification-ts
shell: npm pack

- name: Create Github release
uses: ncipollo/release-action@v1
with:
artifacts: >
ic-response-verification-rs/target/package/ic-response-verification-${{ steps.cz.outputs.version }}.crate
ic-response-verification-ts/dfinity-response-verification-${{ steps.cz.outputs.version }}.tgz
bodyFile: 'RELEASE_NOTES.md'
tag: '${{ steps.cz.outputs.version }}'
commit: 'main'
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- hooks:
- id: commitizen
repo: https://github.com/commitizen-tools/commitizen
rev: v2.35.0
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,20 @@ window.addEventListener('load', async () => {

## Developer Documentation

### Setup

- [Install pre-commit](https://pre-commit.com/#installation)
- [Install commitizen](https://commitizen-tools.github.io/commitizen/#installation)

### Making a Commit

```shell
cz commit
```

See [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for more information on the commit message formats

### Sub Projects

- [Response Verification Rust Crate](./ic-response-verification-rs/README.md)
- [Response Verification NPM Package](./ic-response-verification-ts/README.md)
2 changes: 1 addition & 1 deletion ic-response-verification-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ic-response-verification-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ic-response-verification"
version = "0.1.0"
version = "0.0.0"
edition = "2021"

[dependencies]
Expand Down
4 changes: 3 additions & 1 deletion ic-response-verification-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ic-response-verification-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@dfinity/response-verification",
"version": "0.0.0",
"main": "./lib_wasm_nodejs.js",
"browser": "./lib_wasm_web.js",
"types": "./lib_Wasm_web.d.ts"
Expand Down

0 comments on commit c8ecbc1

Please sign in to comment.