Skip to content

Commit

Permalink
🔀 merge updated workflows to master (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse committed May 15, 2023
1 parent aae0491 commit 636dbc3
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 116 deletions.
59 changes: 26 additions & 33 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ jobs:
- job_001
- job_002
job_004:
name: "unit_test; PKGS: chopper, chopper_built_value; `dart test -p chrome`"
name: "unit_test; PKGS: chopper, chopper_built_value; `dart pub global run coverage:test_with_coverage`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value;commands:test_1"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value;commands:test_with_coverage"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value
os:ubuntu-latest;pub-cache-hosted;sdk:stable
Expand All @@ -144,6 +144,8 @@ jobs:
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: stable
- name: "Activate package:coverage"
run: "dart pub global activate coverage '>=1.5.0'"
- id: checkout
name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
Expand All @@ -152,32 +154,44 @@ jobs:
run: dart pub upgrade
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper
- name: "chopper; dart test -p chrome"
run: dart test -p chrome
- name: "chopper; dart pub global run coverage:test_with_coverage"
run: "dart pub global run coverage:test_with_coverage"
if: "always() && steps.chopper_pub_upgrade.conclusion == 'success'"
working-directory: chopper
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@main
with:
files: chopper/coverage/lcov.info
fail_ci_if_error: true
name: coverage_00
- id: chopper_built_value_pub_upgrade
name: chopper_built_value; dart pub upgrade
run: dart pub upgrade
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper_built_value
- name: "chopper_built_value; dart test -p chrome"
run: dart test -p chrome
- name: "chopper_built_value; dart pub global run coverage:test_with_coverage"
run: "dart pub global run coverage:test_with_coverage"
if: "always() && steps.chopper_built_value_pub_upgrade.conclusion == 'success'"
working-directory: chopper_built_value
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@main
with:
files: chopper_built_value/coverage/lcov.info
fail_ci_if_error: true
name: coverage_01
needs:
- job_001
- job_002
- job_003
job_005:
name: "unit_test; PKGS: chopper, chopper_built_value; `dart test`"
name: "unit_test; PKGS: chopper, chopper_built_value; `dart test -p chrome`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value;commands:test_0"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value;commands:test"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value
os:ubuntu-latest;pub-cache-hosted;sdk:stable
Expand All @@ -195,41 +209,20 @@ jobs:
run: dart pub upgrade
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper
- name: chopper; dart test
run: dart test
- name: "chopper; dart test -p chrome"
run: dart test -p chrome
if: "always() && steps.chopper_pub_upgrade.conclusion == 'success'"
working-directory: chopper
- id: chopper_built_value_pub_upgrade
name: chopper_built_value; dart pub upgrade
run: dart pub upgrade
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper_built_value
- name: chopper_built_value; dart test
run: dart test
- name: "chopper_built_value; dart test -p chrome"
run: dart test -p chrome
if: "always() && steps.chopper_built_value_pub_upgrade.conclusion == 'success'"
working-directory: chopper_built_value
needs:
- job_001
- job_002
- job_003
job_006:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: dart-lang/setup-dart@v1.3
with:
sdk: stable
- id: checkout
uses: actions/checkout@v3
- id: upload_coverage
name: chopper; tool/coverage.sh
run: bash tool/coverage.sh
if: "always() && steps.checkout.conclusion == 'success'"
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
needs:
- job_001
- job_002
- job_003
- job_004
- job_005
75 changes: 49 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,71 @@ env:
permissions: read-all

jobs:
publish_chopper:
name: "Publish chopper"
get_base_version:
name: "Get base version"
runs-on: ubuntu-latest
strategy:
matrix:
package: [ chopper, chopper_generator, chopper_built_value ]
outputs:
BASE_VERSION_chopper: ${{ steps.load_base_version.outputs.BASE_VERSION_chopper }}
BASE_VERSION_chopper_generator: ${{ steps.load_base_version.outputs.BASE_VERSION_chopper_generator }}
BASE_VERSION_chopper_built_value: ${{ steps.load_base_version.outputs.BASE_VERSION_chopper_built_value }}
steps:
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
uses: actions/checkout@v3
- id: credentials
run: |
mkdir -p $XDG_CONFIG_HOME/dart
echo '${{ secrets.CREDENTIAL_JSON }}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json"
- id: publish
run: bash tool/publish.sh chopper
publish_chopper_generator:
name: "Publish chopper_generator"
runs-on: ubuntu-latest
steps:
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
uses: actions/checkout@v3
- id: credentials
ref: ${{ github.event.pull_request.base.ref }}
- name: Load base version
id: load_base_version
run: |
mkdir -p $XDG_CONFIG_HOME/dart
echo '${{ secrets.CREDENTIAL_JSON }}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json"
- id: publish
run: bash tool/publish.sh chopper_generator
publish_chopper_built_value:
name: "Publish chopper_built_value"
set -e
echo "BASE_VERSION_${{ matrix.package }}=$(awk '/^version: / {print $2}' ${{ matrix.package }}/pubspec.yaml)" >> $GITHUB_OUTPUT
publish:
name: "Publish"
needs: get_base_version
runs-on: ubuntu-latest
strategy:
matrix:
package: [ chopper, chopper_generator, chopper_built_value ]
steps:
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
uses: actions/checkout@v3
- id: credentials
- name: Load this version
id: load_this_version
run: |
set -e
echo "THIS_VERSION=$(awk '/^version: / {print $2}' ${{ matrix.package }}/pubspec.yaml)" >> $GITHUB_ENV
- name: Compare versions
id: compare_versions
env:
BASE_VERSION_chopper: ${{ needs.get_base_version.outputs.BASE_VERSION_chopper }}
BASE_VERSION_chopper_generator: ${{ needs.get_base_version.outputs.BASE_VERSION_chopper_generator }}
BASE_VERSION_chopper_built_value: ${{ needs.get_base_version.outputs.BASE_VERSION_chopper_built_value }}
run: |
set -e
pushd tool || exit
dart pub get
echo "IS_VERSION_GREATER=$(dart run compare_versions.dart $THIS_VERSION $BASE_VERSION_${{ matrix.package }})" >> $GITHUB_ENV
popd || exit
- name: Set up pub credentials
id: credentials
if: ${{ env.IS_VERSION_GREATER == 1 }}
run: |
set -e
mkdir -p $XDG_CONFIG_HOME/dart
echo '${{ secrets.CREDENTIAL_JSON }}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json"
- id: publish
run: bash tool/publish.sh chopper_built_value
- name: Publish
id: publish
if: ${{ env.IS_VERSION_GREATER == 1 }}
run: bash tool/publish.sh ${{ matrix.package }}
- name: Skip publish
id: skip_publish
if: ${{ env.IS_VERSION_GREATER == 0 }}
run: echo "Skipping publish for ${{ matrix.package }} because the version is not greater than the one on pub.dev"
64 changes: 46 additions & 18 deletions .github/workflows/publish_dry_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,64 @@ env:
permissions: read-all

jobs:
publish_chopper:
name: "Publish chopper (dry run)"
get_base_version:
name: "Get base version"
runs-on: ubuntu-latest
strategy:
matrix:
package: [ chopper, chopper_generator, chopper_built_value ]
outputs:
BASE_VERSION_chopper: ${{ steps.load_base_version.outputs.BASE_VERSION_chopper }}
BASE_VERSION_chopper_generator: ${{ steps.load_base_version.outputs.BASE_VERSION_chopper_generator }}
BASE_VERSION_chopper_built_value: ${{ steps.load_base_version.outputs.BASE_VERSION_chopper_built_value }}
steps:
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
uses: actions/checkout@v3
- id: publish_dry_run
run: bash tool/publish.sh chopper --dry-run
publish_chopper_generator:
name: "Publish chopper_generator (dry run)"
runs-on: ubuntu-latest
steps:
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
uses: actions/checkout@v3
- id: publish_dry_run
run: bash tool/publish.sh chopper_generator --dry-run
publish_chopper_built_value:
name: "Publish chopper_built_value (dry run)"
ref: ${{ github.event.pull_request.base.ref }}
- name: Load base version
id: load_base_version
run: |
set -e
echo "BASE_VERSION_${{ matrix.package }}=$(awk '/^version: / {print $2}' ${{ matrix.package }}/pubspec.yaml)" >> $GITHUB_OUTPUT
publish_dry_run:
name: "Publish DRY RUN"
needs: get_base_version
runs-on: ubuntu-latest
strategy:
matrix:
package: [ chopper, chopper_generator, chopper_built_value ]
steps:
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
uses: actions/checkout@v3
- id: publish_dry_run
run: bash tool/publish.sh chopper_built_value --dry-run
- name: Load this version
id: load_this_version
run: |
set -e
echo "THIS_VERSION=$(awk '/^version: / {print $2}' ${{ matrix.package }}/pubspec.yaml)" >> $GITHUB_ENV
- name: Compare versions
id: compare_versions
env:
BASE_VERSION_chopper: ${{ needs.get_base_version.outputs.BASE_VERSION_chopper }}
BASE_VERSION_chopper_generator: ${{ needs.get_base_version.outputs.BASE_VERSION_chopper_generator }}
BASE_VERSION_chopper_built_value: ${{ needs.get_base_version.outputs.BASE_VERSION_chopper_built_value }}
run: |
set -e
pushd tool || exit
dart pub get
echo "IS_VERSION_GREATER=$(dart run compare_versions.dart $THIS_VERSION $BASE_VERSION_${{ matrix.package }})" >> $GITHUB_ENV
popd || exit
- name: Publish (dry run)
id: publish_dry_run
if: ${{ env.IS_VERSION_GREATER == 1 }}
run: bash tool/publish.sh ${{ matrix.package }} --dry-run
- name: Skip publish (dry run)
id: skip_publish_dry_run
if: ${{ env.IS_VERSION_GREATER == 0 }}
run: echo "Skipping publish (dry run) for ${{ matrix.package }} because the version is not greater than the one on pub.dev"
2 changes: 1 addition & 1 deletion chopper/mono_pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ stages:
- format
- analyze: --fatal-infos .
- unit_test:
- test:
- test_with_coverage:
- test: -p chrome

cache:
Expand Down
2 changes: 1 addition & 1 deletion chopper_built_value/mono_pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ stages:
- format
- analyze: --fatal-infos .
- unit_test:
- test:
- test_with_coverage:
- test: -p chrome

cache:
Expand Down
30 changes: 9 additions & 21 deletions mono_repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,16 @@ github:
on:
push:
branches:
- master
- develop
- master
- develop
pull_request:
branches:
- master
- develop
on_completion:
- name: "Coverage"
runs-on: ubuntu-latest
steps:
- uses: dart-lang/setup-dart@v1.3
with:
sdk: stable
- id: checkout
uses: actions/checkout@v3
- id: upload_coverage
name: "chopper; tool/coverage.sh"
if: "always() && steps.checkout.conclusion == 'success'"
run: bash tool/coverage.sh
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- master
- develop

merge_stages:
- analyzer_and_format
- unit_test
- analyzer_and_format
- unit_test

coverage_service:
- codecov
10 changes: 5 additions & 5 deletions tool/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ for PKG in ${PKGS}; do
echo 'dart format --output=none --set-exit-if-changed .'
dart format --output=none --set-exit-if-changed . || EXIT_CODE=$?
;;
test_0)
echo 'dart test'
dart test || EXIT_CODE=$?
;;
test_1)
test)
echo 'dart test -p chrome'
dart test -p chrome || EXIT_CODE=$?
;;
test_with_coverage)
echo 'dart pub global run coverage:test_with_coverage'
dart pub global run coverage:test_with_coverage || EXIT_CODE=$?
;;
*)
echo -e "\033[31mUnknown TASK '${TASK}' - TERMINATING JOB\033[0m"
exit 64
Expand Down
Loading

0 comments on commit 636dbc3

Please sign in to comment.