Fix file tests #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Review | |
on: | |
pull_request: | |
types: [opened, reopened, ready_for_review] | |
paths: | |
- "**.dart" | |
- "pubspec.lock" | |
branches: | |
- main | |
env: | |
MIN_COVERAGE: 85 | |
jobs: | |
validate_version_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get latest tag from repository | |
id: latest_tag | |
run: | | |
LATEST_TAG=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' --refs origin "refs/tags/*" | awk '{print substr($2, 11)}' | tail -n1) | |
echo "tag=${LATEST_TAG}" >> $GITHUB_OUTPUT | |
- name: Get latest version number of CHANGELOG.md | |
id: get_latest_changelog_version | |
run: | | |
LATEST_CHANGELOG_VERSION_NUMBER=$(grep -m 1 -oP '## \[(?!Unreleased)[^\]]+\]' CHANGELOG.md | sed 's/## \[\(.*\)\]/\1/') | |
echo "version_number=${LATEST_CHANGELOG_VERSION_NUMBER}" >> $GITHUB_OUTPUT | |
- name: Compare versions | |
run: | | |
LATEST_TAG=${{ steps.latest_tag.outputs.tag }} | |
VERSION=v${{ steps.get_latest_changelog_version.outputs.version_number }} | |
if [[ "$LATEST_TAG" == "$VERSION" ]]; then | |
echo "Version from CHANGELOG.md ($VERSION) is the same than the latest tag ($LATEST_TAG)" | |
exit 1 | |
fi | |
if [[ "$(printf '%s\n' "$VERSION" "$LATEST_TAG" | tr '-' '~' | sort -V | head -n1 | tr '~' '-')" != "$LATEST_TAG" ]]; then | |
echo "Version from CHANGELOG.md ($VERSION) is not greater than the latest tag ($LATEST_TAG)" | |
exit 1 | |
fi | |
echo "Version from CHANGELOG.md ($VERSION) is greater than the latest tag ($LATEST_TAG)" | |
- name: Restore Cache dependencies | |
id: restore-cache-deps | |
uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }} | |
path: ~/.pub-cache | |
- name: Setup Dart | |
uses: dart-lang/setup-dart@v1 | |
- name: Install dependencies | |
run: dart pub get | |
- name: Save Cache dependencies | |
uses: actions/cache/save@v3 | |
if: steps.restore-cache-deps.outputs.cache-hit != 'true' | |
with: | |
key: ${{ steps.restore-cache-deps.outputs.cache-primary-key }} | |
path: ~/.pub-cache | |
- name: Analyze project source | |
run: dart analyze | |
- name: Install Global Dependencies | |
run: | | |
dart pub global activate dlcov "<5.0.0" | |
dart pub global activate coverage "<2.0.0" | |
- name: Run tests | |
run: | | |
test_with_coverage --function-coverage --branch-coverage | |
- name: Analyze coverage | |
run: | | |
dlcov --coverage=$MIN_COVERAGE --include-untested-files=true | |