Skip to content

Commit

Permalink
ci: automate release flow (#18)
Browse files Browse the repository at this point in the history
This commit arranges the automated release flow similar to other repositories like [deno_media_type] or [deno_ast].

[deno_media_type]: https://github.com/denoland/deno_media_type
[deno_ast]: https://github.com/denoland/deno_ast
  • Loading branch information
magurotuna committed Jan 17, 2024
1 parent e9a4ebd commit 8c130e4
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 11 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
name: ci

on: [push, pull_request]
on:
pull_request:
branches: [main]
push:
branches: [main]
tags:
- '*'

jobs:
rust:
if: |
github.event_name == 'push' ||
!startsWith(github.event.pull_request.head.label, 'denoland:')
runs-on: ubuntu-latest
timeout-minutes: 30

env:
GH_ACTIONS: 1
RUST_BACKTRACE: full
RUSTFLAGS: -D warnings

steps:
- name: Clone repository
uses: actions/checkout@v4
Expand All @@ -18,11 +28,22 @@ jobs:
toolchain: stable
components: clippy,rustfmt

- name: Build
run: cargo build --release --all-targets
- name: Format
run: cargo fmt --all --check

- name: Lint
run: cargo clippy --all-targets --all-features --release

- name: Test
run: cargo test --release --all-targets
run: cargo test --release --all-targets --all-features

- name: Lint
run: cargo clippy --all-targets
- name: Build
run: cargo build --release --all-targets --all-features

- name: Publish
if: |
github.repository == 'denoland/flaky_test' &&
startsWith(github.ref, 'refs/tags/')
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: release

on:
workflow_dispatch:
inputs:
releaseKind:
description: 'Kind of release'
type: choice
options:
- patch
- minor
- major
required: true

jobs:
rust:
name: release
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
token: ${{ secrets.DENOBOT_PAT }}

- uses: denoland/setup-deno@v1
- uses: dtolnay/rust-toolchain@stable

- name: Tag and release
env:
GITHUB_TOKEN: ${{ secrets.DENOBOT_PAT }}
GH_WORKFLOW_ACTOR: ${{ github.actor }}
run: |
git config user.email "denobot@users.noreply.github.com"
git config user.name "denobot"
deno run -A https://github.com/raw/denoland/automation/0.20.0/tasks/publish_release.ts --${{github.event.inputs.releaseKind}}
4 changes: 2 additions & 2 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ fn fail_first_nine_times() {
#[flaky_test]
#[should_panic]
fn fail_three_times() {
assert!(false);
panic!("should panic");
}

#[flaky_test(times = 10)]
#[should_panic]
fn fail_ten_times() {
assert!(false);
panic!("should panic");
}

#[flaky_test(tokio)]
Expand Down

0 comments on commit 8c130e4

Please sign in to comment.