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

Basic CI setup #2

Merged
merged 2 commits into from
Oct 30, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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