Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlademann-wf committed Mar 27, 2024
1 parent 1d5f538 commit 0165f7f
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 57 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: setup

on:
workflow_call:
inputs:
sdk:
required: true

permissions:
contents: read
id-token: write
issues: write
pull-requests: write

jobs:
install:
uses: ./install.yml
with:
sdk: ${{ inputs.sdk }}
secrets: inherit

build:
needs: [install]
runs-on: ubuntu-latest
steps:
# Analyze before generated files are created to verify that component boilerplate analysis is "clean" without the need for building
- name: Analyze source (pre-build)
id: analyze-prebuild
run: |
# Analyze lib to ensure public APIs don't depend on build-to-cache files,
# which could cause analysis issues for consumers who haven't run a build yet.
dart analyze lib
dart analyze example/boilerplate_versions
- name: Restore pub cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: .dart_tool
key: ${{ needs.install.outputs.hash }}

- name: Precompile DDC
id: precompile
timeout-minutes: 6
if: steps.cache-restore.outputs.cache-hit != 'true'
run: dart run build_runner build --delete-conflicting-outputs -o ddc_precompiled

- name: Save pub cache
id: cache-save
uses: actions/cache/save@v4
with:
path: .dart_tool
key: ${{ needs.install.outputs.hash }}

- name: Verify that generated files are up-to-date
if: steps.precompile.outcome == 'success' || steps.precompile.outcome == 'skipped'
run: |
if [ ${{ inputs.sdk }} = '2.18.7' ]; then
git diff --exit-code
else
# Don't check these generated files for other SDKs, since they may generate differently
# due to different resolved dependencies.
git diff --exit-code -- ":(exclude)test/mockito.mocks.dart" ":(exclude)test/over_react/component_declaration/redux_component_test/test_reducer.g.dart"
fi
# Analyze again after generated files are created to verify that those generated classes don't cause analysis errors
- name: Analyze source (post-build)
if: steps.precompile.outcome == 'success' || steps.precompile.outcome == 'skipped'
run: dart analyze
130 changes: 73 additions & 57 deletions .github/workflows/dart_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,96 @@ on:
- '**'

jobs:
build:
# setup:
# uses: ./build.yml
# sdk: ${{ steps.test.matrix.sdk }}
# secrets: inherit
test:
# needs: [setup]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Can't run on `dev` (Dart 3) until we're fully null-safe.
sdk: [ 2.18.7, 2.19.6 ]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v0.2
with:
sdk: ${{ matrix.sdk }}

- name: Print Dart SDK version
run: dart --version

- id: install
name: Install dependencies
run: dart pub get

- name: Validate dependencies
run: dart run dependency_validator
if: always() && steps.install.outcome == 'success'

- name: Verify formatting
run: dart run dart_dev format --check
# Only run on one sdk version in case there are conflicts
if: always() && matrix.sdk != '2.18.7' && steps.install.outcome == 'success'
# - uses: actions/checkout@v3
# - uses: dart-lang/setup-dart@v1
# with:
# sdk: ${{ matrix.sdk }}
#
# - name: Print Dart SDK version
# run: dart --version
#
# - id: install
# name: Install dependencies
# run: dart pub get
#
# - name: Validate dependencies
# run: dart run dependency_validator
# if: always() && steps.install.outcome == 'success'
#
# - name: Verify formatting
# run: dart run dart_dev format --check
# # Only run on one sdk version in case there are conflicts
# if: always() && matrix.sdk != '2.18.7' && steps.install.outcome == 'success'

# Analyze before generated files are created to verify that component boilerplate analysis is "clean" without the need for building
- name: Analyze example source (pre-build)
run: |
# Analyze lib to ensure public APIs don't depend on build-to-cache files,
# which could cause analysis issues for consumers who haven't run a build yet.
dart analyze lib
dart analyze example/boilerplate_versions
if: always() && steps.install.outcome == 'success'

- id: build
timeout-minutes: 6
name: Build generated files / precompile DDC assets
run: |
dart run build_runner build --delete-conflicting-outputs -o ddc_precompiled
if: always() && steps.install.outcome == 'success'

- name: Verify that generated files are up-to-date
run: |
if [ ${{ matrix.sdk }} = '2.18.7' ]; then
git diff --exit-code
else
# Don't check these generated files for other SDKs, since they may generate differently
# due to different resolved dependencies.
git diff --exit-code -- ":(exclude)test/mockito.mocks.dart" ":(exclude)test/over_react/component_declaration/redux_component_test/test_reducer.g.dart"
fi
if: always() && steps.install.outcome == 'success' && steps.install.build == 'success'

# Analyze again after generated files are created to verify that those generated classes don't cause analysis errors
- name: Analyze project source (post-build)
run: dart analyze
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'
# - name: Analyze example source (pre-build)
# run: |
# # Analyze lib to ensure public APIs don't depend on build-to-cache files,
# # which could cause analysis issues for consumers who haven't run a build yet.
# dart analyze lib
# dart analyze example/boilerplate_versions
# if: always() && steps.install.outcome == 'success'
#
# - id: build
# timeout-minutes: 6
# name: Build generated files / precompile DDC assets
# run: |
# dart run build_runner build --delete-conflicting-outputs -o ddc_precompiled
# if: always() && steps.install.outcome == 'success'
#
# - name: Verify that generated files are up-to-date
# run: |
# if [ ${{ matrix.sdk }} = '2.18.7' ]; then
# git diff --exit-code
# else
# # Don't check these generated files for other SDKs, since they may generate differently
# # due to different resolved dependencies.
# git diff --exit-code -- ":(exclude)test/mockito.mocks.dart" ":(exclude)test/over_react/component_declaration/redux_component_test/test_reducer.g.dart"
# fi
# if: always() && steps.install.outcome == 'success' && steps.install.build == 'success'
#
# # Analyze again after generated files are created to verify that those generated classes don't cause analysis errors
# - name: Analyze project source (post-build)
# run: dart analyze
# if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'
- name: Install
id: setup
uses: ./install.yml
with:
sdk: ${{ matrix.sdk }}

- name: Run tests (VM)
# Can't use build_runner (which dart_dev uses if you depend on it) to run VM tests, since we get the error:
# Unable to spawn isolate: /…/build_runner_testRU6M77/.packages: Error: Problem in packages configuration file: Unexpected character
run: dart test -P vm
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'

- name: Run tests (DDC)
run: dart test --precompiled ddc_precompiled -P dartdevc
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'
if: steps.setup.outcome == 'success'

- name: Run tests (dart2js)
run: dart run dart_dev test --build-args="-r" -P dart2js
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'
if: steps.setup.outcome == 'success'

- name: Build
id: build
uses: ./build.yml
with:
sdk: ${{ matrix.sdk }}

- name: Run tests (DDC)
run: dart test --precompiled ddc_precompiled -P dartdevc
if: steps.build.outcome == 'success'

validate_analyzer:
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/dart_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test

on:
workflow_call:
inputs:
sdk:
required: true

permissions:
contents: read
id-token: write
issues: write
pull-requests: write

jobs:
ddc:
runs-on: ubuntu-latest


52 changes: 52 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: install

on:
workflow_call:
inputs:
sdk:
required: true

permissions:
contents: read
id-token: write
issues: write
pull-requests: write

jobs:
install:
runs-on: ubuntu-latest
outputs:
hash: ${{ steps.hash.outputs.result }}
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}
- name: Print Dart SDK version
run: dart --version
- name: Produce hash
id: hash
shell: bash
run: echo "result=${{ runner.os }};${{ hashFiles('**/pubspec.yaml','**/pubspec.lock') || 'none' }}@${{ inputs.sdk }}" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
name: Pub Cache
id: cache
with:
path: .dart_tool
key: ${{ steps.hash.outputs.result }}

- name: Install Dependencies
id: install
if: steps.cache.outputs.cache-hit != 'true'
run: dart pub get

check:
needs: [install]
steps:
- name: Validate Dependencies
run: dart run dependency_validator
- name: Verify formatting
# Only run on one sdk version in case there are conflicts
if: inputs.sdk != '2.18.7'
run: dart run dart_dev format --check

0 comments on commit 0165f7f

Please sign in to comment.