Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Hello remote config (#34) #78

Hello remote config (#34)

Hello remote config (#34) #78

Workflow file for this run

name: Main Workflow - Dart package
on:
push:
branches:
- main
paths-ignore:
- '.gitignore'
- '.metadata'
- '.github/**'
- '*.md'
pull_request:
paths-ignore:
- '.github/**'
- '*.md'
- '.metadata'
workflow_dispatch:
env:
min_coverage: 50
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
delete_bot_comments:
name: Delete bot comments on PR.
runs-on: ubuntu-latest
steps:
- uses: izhangzhihao/delete-comment@master
if: ${{ github.event_name == 'pull_request' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
delete_user_name: github-actions[bot]
issue_number: ${{ github.event.number }}
tag_validation:
name: Tag validation
runs-on: ubuntu-latest
outputs:
version: ${{ steps.split.outputs._0 }}
needs:
- delete_bot_comments
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4
- name: Get version number from the pubspec.yaml
id: pubspecVersion
uses: CumulusDS/[email protected]
with:
file: pubspec.yaml
version: version
- uses: jungwinter/split@v2
id: split
with:
msg: ${{ steps.pubspecVersion.outputs.version }}
seperator: '+'
- name: Validate that version doesn't exists
uses: mukunku/[email protected]
id: checkTag
with:
tag: ${{ steps.split.outputs._0 }}
- name: 💬 Post comment on PR and fail.
if: ${{ steps.checkTag.outputs.exists == 'true' && github.event_name == 'pull_request' }}
run: |
gh pr comment ${{ github.event.pull_request.number }} -b '${{ steps.split.outputs._0 }} already exists, please update the pubspec version.'
exit 1
build:
name: Build and test
runs-on: ubuntu-latest
needs:
- delete_bot_comments
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4
- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1
- name: 📦 Install Dependencies
run: dart pub get
- name: ✨ Formatting lib and test directories
run: dart format lib test
- name: ✉️ Commit formatted files
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: "*.dart"
commit_user_name: Github Actions Bot
commit_message: "[BOT] Applying dart format."
add_options: '-u'
- name: 🕵️ Analyze
run: dart analyze --fatal-warnings lib test
- name: 🧪 Run Tests
run: |
dart pub global activate coverage
export PATH=$PATH:$HOME/.pub-cache/bin
dart pub global run coverage:test_with_coverage
- name: 💬 Comment coverage details on the PR
if: ${{ github.event_name == 'pull_request' }}
uses: romeovs/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: ./coverage/lcov.info
- name: 📊 Check Code Coverage
id: check_coverage
if: ${{ github.event_name == 'pull_request' }}
uses: VeryGoodOpenSource/very_good_coverage@v3
with:
path: ./coverage/lcov.info
min_coverage: ${{ env.min_coverage }}
- name: 💬 Comment coverage too low
if: ${{ failure() && steps.check_coverage.outcome == 'failure' && github.event_name == 'pull_request' }}
run: |
gh pr comment ${{ github.event.pull_request.number }} -b 'Coverage too low, please improve the test to ${{ env.min_coverage }}% at least.'
- name: ✉️ Commit coverage badge
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: "coverage_badge.svg"
commit_user_name: Github Actions Bot
commit_message: "[BOT] Update coverage badge."
add_options: '-u'
pre_release:
name: Pre-release the package on Github.
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
needs:
- tag_validation
- build
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create pre-release
run: |
gh release create ${{ needs.tag_validation.outputs.version }} --title v${{ needs.tag_validation.outputs.version }} -R '${{ github.repository }}' --prerelease --generate-notes