Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial commit #2

Merged
merged 24 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/_gha_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 🏗️ CI

on:
pull_request:
push:
branches:
- master
tags:
- '**'

permissions:
contents: read
id-token: write

jobs:
build:
runs-on: [self-hosted, xs, al2023]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok these 2 jobs are running on self-hosted runners?

steps:
- uses: Workiva/[email protected]
# Even though we aren't uploading a specific artifact, the
# store artifacts action uploads a build.txt and marks the
# github action run as "the build" for integration with
# workiva release pipelines
- uses: Workiva/[email protected]
test:
runs-on: [self-hosted, xs, al2023]
steps:
- uses: Workiva/[email protected]
# Even though we have no test artifacts to actually upload
# we need to run gha-upload-test-reports to satisfy the
# auto QA pipeline rule
- uses: Workiva/[email protected]

25 changes: 25 additions & 0 deletions .github/workflows/_test:checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 🧪 checks

on:
push:
branches:
- master
pull_request:
paths:
- __tests__/fixtures/checks/**
- .github/workflows/checks.yaml
- .github/workflows/_test:checks.yaml

jobs:
checks:
uses: ./.github/workflows/checks.yaml
with:
package-path: __tests__/fixtures/checks

checks-with-additional:
uses: ./.github/workflows/checks.yaml
with:
package-path: __tests__/fixtures/checks
additional-checks: |
echo "all good!"
dart format
22 changes: 22 additions & 0 deletions .github/workflows/_test:test-unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 🧪 test-unit

on:
push:
branches:
- master
pull_request:
paths:
- __tests__/fixtures/test-unit/**
- .github/workflows/test-unit.yaml
- .github/workflows/_test:test-unit.yaml

jobs:
test-unit-without-chrome:
uses: ./.github/workflows/test-unit.yaml
with:
package-path: __tests__/fixtures/test-unit/without-chrome

test-unit-with-chrome:
uses: ./.github/workflows/test-unit.yaml
with:
package-path: __tests__/fixtures/test-unit/with-chrome
107 changes: 107 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
on:
workflow_call:
inputs:
package-path:
description: The path to the package to run checks on
default: '.'
type: string

additional-checks:
description: >
Any commands to run along with the hardcoded defaults. Enter multiple
commands on different lines. Failure conditions are based on if any
provided command results in a non-zero exit code, OR modifies the source.
type: string

sdk:
description: See https://github.com/dart-lang/setup-dart
default: 2.19.6
type: string

jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}
- working-directory: ${{ inputs.package-path }}
run: dart run dart_dev analyze


format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}
- name: Run format
working-directory: ${{ inputs.package-path }}
run: dart run dart_dev format --check

dependency-validator:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}

- name: Install Dependency Validator
run: dart pub global activate dependency_validator ^3.2.3

- name: Install Package Dependencies
working-directory: ${{ inputs.package-path }}
run: dart pub get
todbachman-wf marked this conversation as resolved.
Show resolved Hide resolved

- name: Run Dependency Validator
working-directory: ${{ inputs.package-path }}
run: dart pub global run dependency_validator

analyze-additional-checks:
runs-on: ubuntu-latest
if: inputs.additional-checks != ''
outputs:
checks: ${{ steps.analyze.outputs.checks }}
steps:
- name: Analyze Checks
id: analyze
run: |
checks=$(cat <<-END
${{ inputs.additional-checks }}
END)
checks_json=$(echo "$checks" | jq -R . | jq -scM .)
echo "checks=$checks_json" >> $GITHUB_OUTPUT

additional-checks:
runs-on: ubuntu-latest
needs: analyze-additional-checks
strategy:
fail-fast: false
matrix:
check: ${{ fromJson(needs.analyze-additional-checks.outputs.checks) }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}

- name: Install Package Dependencies
working-directory: ${{ inputs.package-path }}
run: dart pub get

- name: Run '${{ matrix.check }}'
run: ${{ matrix.check }}
working-directory: ${{ inputs.package-path }}

- name: Check for source changes
run: |
git diff --quiet -- . ':(exclude)**pubspec.lock' || {
echo "::error::The '${{ matrix.check }}' failed with source changes"
git --no-pager diff -- . ':(exclude)**pubspec.lock'
exit 1
}


37 changes: 37 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
workflow_call:
inputs:
sdk:
description: See https://github.com/dart-lang/setup-dart
default: 2.19.6
type: string

jobs:
create-sbom-release-asset:
name: Create SBOM Release Asset
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish SBOM to Release Assets
uses: anchore/sbom-action@v0
with:
path: ./
format: cyclonedx-json

publish:
name: Publish to pub.dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}

- name: Install dependencies
run: dart pub get

- name: Publish - dry run
run: dart pub publish --dry-run

- name: Publish
run: dart pub publish -f
113 changes: 113 additions & 0 deletions .github/workflows/test-unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
on:
workflow_call:
inputs:
preset:
description: >
Any preset to specify when running dart test, see the 'test' packages
documentation on presets for more information.
type: string

browser-aggregation:
description: >
Whether or not to run the test with the --browser-aggregation flag. See test_html_builder's
readme for more information: https://github.com/Workiva/test_html_builder#aggregating-browser-tests
default: false
type: boolean

test-inputs:
description: Optional path(s) to a specific test file(s) passed to the dart test command
type: string

test-args:
description: Arguments passed directly to the dart test command
type: string

package-path:
description: A path to the package to run unit tests against
type: string
default: '.'

timeout:
description: A timeout, specificed in minutes, for the dart test command
default: 15
type: number

sdk:
description: See https://github.com/Workiva/gha-dart/blob/master/setup-dart/README.md
default: 2.19.6
type: string

jobs:
pre:
runs-on: ubuntu-latest
outputs:
has-chrome-platform: ${{ steps.analyze.outputs.HAS_CHROME_PLATFORM }}
steps:
- uses: actions/checkout@v4
- name: Install yq
run: |
sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- working-directory: ${{ inputs.package-path }}
id: analyze
run: |
if [[ -f 'dart_test.yaml' ]]; then
platforms=$(yq '.platforms[], .presets.*.platforms[]' dart_test.yaml)

if [[ "$platforms" == *"chrome"* ]]; then
echo "Project has chrome platform config"
echo "HAS_CHROME_PLATFORM=true" >> $GITHUB_OUTPUT
exit 0
fi
fi
echo "Project does not have chrome platform config"
echo "HAS_CHROME_PLATFORM=false" >> $GITHUB_OUTPUT

unit:
runs-on: ubuntu-latest
needs: pre
name: ${{ matrix.release-mode && 'dev' || 'release' }}
strategy:
fail-fast: false
matrix:
release-mode: ${{ fromJson(needs.pre.outputs.has-chrome-platform == 'true' && '[true, false]' || '[false]') }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}

- name: Setup Chrome
if: needs.pre.outputs.has-chrome-platform == 'true'
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
- name: Setup Chrome Alias
if: needs.pre.outputs.has-chrome-platform == 'true'
run: alias google-chrome="/opt/hostedtoolcache/chromium/stable/x64/chrome"

- name: Pub get
working-directory: ${{ inputs.package-path }}
run: dart pub get

- name: Run dart_dev unit tests
working-directory: ${{ inputs.package-path }}
run: |
args=()
if [[ "${{ matrix.release-mode }}" == "true" ]]; then
args+=(--release)
fi

if [[ "${{ inputs.browser-aggregation }}" == "true" ]]; then
args+=(--browser-aggregation)
fi

if [[ "${{ inputs.preset }}" != "" ]]; then
args+=(-P ${{ inputs.preset }})
fi

if [[ "${{ inputs.test-args }}" != "" ]]; then
args+=(--test-args="${{ inputs.test-args }}")
fi

timeout ${{ inputs.timeout }}m dart run dart_dev test "${args[@]}" ${{ inputs.test-inputs }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pubspec.lock
.dart_tool
Loading