Skip to content

Commit

Permalink
Merge pull request #2 from KevinnZou/feature/ci_support Basic CI setup
Browse files Browse the repository at this point in the history
Basic CI setup
  • Loading branch information
KevinnZou committed Oct 30, 2023
2 parents be1f7ec + b4034b7 commit c20848c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build Multiplatform project
on:
push:
branches:
- main
- feature/ci_support
pull_request:

jobs:
build-multiplatform-project:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-12, windows-2022]
gradle: [8.3]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
- name: Build Multiplatform project
shell: bash
run: ./gradlew assemble
20 changes: 20 additions & 0 deletions .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Check code style
on:
push:
branches:
- main
- feature/ci_support
pull_request:

jobs:
check-code-style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
- name: Check code style
shell: bash
run: ./gradlew ktlintCheck
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ and contains the following changes:
* Add a `lib` module for the shared library code.
* Move the androidApp and iosApp modules to the `samples` folder.
* Apply the `org.jetbrains.dokka` plugin to generate documentation for the library code.
* Set up a GitHub Action to publish the documentation to GitHub Pages.
* Apply the `com.vanniktech.maven.publish` plugin to streamline the process of publishing a library.
* Apply the `org.jlleitschuh.gradle.ktlint` plugin to enforce the code style and set up the git hooks to fix the code style before committing automatically.
* Set up the CI pipeline to build the project, check the code style, and publish the documentation.

**Note**: If you also want to make your library support Desktop target, please use this template https://github.com/KevinnZou/compose-multiplatform-library-template

Expand Down Expand Up @@ -86,6 +86,33 @@ To install the git hooks, run the following command:
```
Then you can commit the code without worrying about the code style.

## CI/CD
This template uses GitHub Actions to set up a CI/CD pipeline.
Currently, the pipeline is configured to do three things:

### Build the project
The pipeline is triggered on every push to the `main` branch or on every pull request.
It builds the project and runs the tests.

The pipeline is defined in [`.github/workflows/build.yml`](https://github.com/KevinnZou/compose-multiplatform-library-template/blob/feature/ci_support/.github/workflows/build.yml).

### Check the code style
The pipeline is triggered on every push to the `main` branch or on every pull request.
It checks the code style and fails if the code style is not correct.

The pipeline is defined in [`.github/workflows/code_style.yml`](https://github.com/KevinnZou/compose-multiplatform-library-template/blob/feature/ci_support/.github/workflows/code_style.yml).

If the code style is not correct, you can run the following command to fix it:
```shell
./gradlew ktlintFormat
```

### Publish the documentation
The pipeline is triggered on every push to the `main` branch or on every pull request.
It generates the documentation and publishes it to GitHub Pages.

The pipeline is defined in [`.github/workflows/wiki.yml`](https://github.com/KevinnZou/compose-multiplatform-library-template/blob/feature/ci_support/.github/workflows/wiki.yml).

## Dokka

This template applies the `org.jetbrains.dokka` plugin to generate documentation for the library code.
Expand Down

0 comments on commit c20848c

Please sign in to comment.