From 05103de0d25139e6c2ae2093c69640519f65f3e3 Mon Sep 17 00:00:00 2001 From: lowit Date: Wed, 18 Dec 2024 19:31:48 +0300 Subject: [PATCH] 12: add ci closes #12 --- .github/dependabot.yml | 7 +++ .github/workflows/auto_dependabot.yml | 27 ++++++++++ .github/workflows/release.yml | 16 ++++++ .github/workflows/test.yml | 71 +++++++++++++++++++++++++++ MAINTENANCE.md | 41 ++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/auto_dependabot.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 MAINTENANCE.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a626bc6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: cargo + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/workflows/auto_dependabot.yml b/.github/workflows/auto_dependabot.yml new file mode 100644 index 0000000..e0da855 --- /dev/null +++ b/.github/workflows/auto_dependabot.yml @@ -0,0 +1,27 @@ +name: Auto Dependabot +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1.1.1 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Approve a PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..431327b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,16 @@ +name: Release + +on: + release: + types: [released] + +jobs: + release-crate: + name: release crate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: "1.81.0" + - run: cargo publish --locked --token ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8f40d28 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,71 @@ +name: Tests + +on: + push: + branches: + - master + pull_request: + +jobs: + pre_job: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + skip_after_successful_duplicate: "true" + paths_ignore: '["**/*.md", "**/*.svg", "**/*.png", ".gitignore"]' + + lint_check: + needs: pre_job + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: "1.81.0" + components: clippy + override: true + - name: Checking code format + run: cargo fmt -- --check --config use_try_shorthand=true + - name: Clippy + uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features --bins --examples --tests --benches -- -D warnings + + tests: + needs: pre_job + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: "1.81.0" + override: true + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features diff --git a/MAINTENANCE.md b/MAINTENANCE.md new file mode 100644 index 0000000..f2275b1 --- /dev/null +++ b/MAINTENANCE.md @@ -0,0 +1,41 @@ +# Maintenance guide + +## Making a new release + +1. Update master branch + + ```shell + git checkout master && git pull + ``` + +1. Update project version in `Cargo.toml` + + ```shell + vim Cargo.toml + ``` + +1. Update `Cargo.lock` + + ```shell + cargo update + ``` + +1. Commit `Cargo.toml` and `Cargo.lock` with the version + + ```shell + git commit -m "bump version" Cargo.toml Cargo.lock + ``` + +1. Make a new git tag + + ```shell + git tag + ``` + +1. Push all to upstream + + ```shell + git push origin master --tags + ``` + +1. [Create](https://github.com/lowitea/gitlobster/releases/new) a new release specifying pushed tag