ci #49
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: ci | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
schedule: | |
- cron: "0 0 * * 0" # every Sunday at 00:00 UTC | |
workflow_dispatch: # allow manual triggering | |
concurrency: | |
group: ci-${{ github.ref }}-0 # ensure only one build per branch is running at a time | |
cancel-in-progress: true | |
jobs: | |
pre-cache: | |
# This job is used to setup the runner and cache the setup once per os. | |
# This is done to avoid running the setup multiple times in parallel later during test. | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- id: setup-env | |
shell: bash | |
run: | | |
export PURO_ROOT=$(dirname $GITHUB_WORKSPACE)/puro | |
echo PURO_ROOT=$PURO_ROOT >> $GITHUB_ENV | |
- id: cache-check | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.PURO_ROOT }} | |
lookup-only: true | |
key: setup-runner-${{ runner.os }}-${{ runner.arch }}- | |
restore-keys: setup-runner-${{ runner.os }}-${{ runner.arch }}- | |
- uses: actions/checkout@v4 | |
if: steps.cache-check.outputs.cache-matched-key == '' | |
- name: Setup runner | |
if: steps.cache-check.outputs.cache-matched-key == '' | |
uses: ./.github/actions/setup-runner | |
build: | |
needs: pre-cache | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup runner | |
uses: ./.github/actions/setup-runner | |
- name: Install dependencies | |
run: dart pub get --no-example | |
- name: Install example dependencies | |
run: flutter pub get | |
working-directory: example | |
- name: Verify formatting | |
run: dart format --output=none --set-exit-if-changed . | |
- name: Analyze package and example source | |
run: dart analyze --fatal-infos . | |
- name: Check PANA score | |
run: | | |
dart pub global activate pana && \ | |
dart pub global run pana --no-warning --exit-code-threshold=0 --json \ | |
--flutter-sdk $(flutter --no-version-check --version --machine | jq -r '.flutterRoot') | |
- name: Publish Dry Run | |
run: dart pub publish --dry-run | |
- name: Generate test coverage | |
run: | | |
dart pub global activate coverage && \ | |
dart pub global run coverage:test_with_coverage --branch-coverage --function-coverage | |
- name: Upload coverage | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage/lcov.info | |
test: | |
needs: build | |
runs-on: ${{ matrix.os }} | |
continue-on-error: ${{ matrix.channel != 'stable' }} # allow failures on beta/master channel | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
channel: [stable, beta, master] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup runner | |
uses: ./.github/actions/setup-runner | |
with: | |
flutter-version: ${{ matrix.channel }} | |
- name: Run tests | |
run: dart test --reporter=expanded --concurrency=1 |