Skip to content

Commit

Permalink
Added automated CI testing and autopublish on release
Browse files Browse the repository at this point in the history
  • Loading branch information
Sterling Long committed Mar 4, 2023
1 parent 9273af5 commit 2a37693
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ci
description: Executes Dart specific CI steps.
inputs:
type:
description: The type of CI to run.
required: true
node-url:
description: 'The endpoint of the Pact node to test with'
required: false
default: 'https://api.chainweb.com'

runs:
using: composite
steps:
# Setup Dependencies
- uses: ./.github/actions/dependencies

# Unit and Integration Tests
- name: Run tests
if: inputs.type == 'integration-tests'
shell: bash
env:
NODE_URL: ${{ inputs.node-url }}
run: flutter test --dart-define=RELAY_ENDPOINT=$RELAY_ENDPOINT --dart-define=PROJECT_ID=$PROJECT_ID

27 changes: 27 additions & 0 deletions .github/actions/dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ci
description: Installs dependencies

runs:
using: composite
steps:
# General Tests
- name: Install packages
shell: bash
run: flutter pub get

# - name: Generate code
# shell: bash
# run: flutter pub run build_runner build --delete-conflicting-outputs

- name: Install packages for example
shell: bash
run: cd example/dapp && flutter pub get && cd ../..

- name: Verify formatting and analyze project source
shell: bash
run: dart format --output=none --set-exit-if-changed .

# - name: Analyze project source
# shell: bash
# run: flutter analyze

24 changes: 24 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Description

<!--
Please include:
* summary of the changes and the related issue
* relevant motivation and context
-->

Resolves # (issue)

## How Has This Been Tested?

<!--
Please:
* describe the tests that you ran to verify your changes.
* provide instructions so we can reproduce.
-->

<!-- If valid for smoke test on feature add screenshots -->

## Due Dilligence

* [ ] Breaking change
* [ ] Requires a documentation update
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: ci

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

workflow_dispatch:


concurrency:
# Support push/pr as event types with different behaviors each:
# 1. push: queue up builds by branch
# 2. pr: only allow one run per PR
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name }}
# If there is already a workflow running for the same pull request, cancel it
# For non-PR triggers queue up builds
cancel-in-progress: ${{ github.event_name == 'pull_request' }}


jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
test-type: [unit-tests]

steps:
- uses: actions/checkout@v3

- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.10'

- uses: ./.github/actions/ci
with:
type: ${{ matrix.test-type }}
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish to pub.dev

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
publish:
name: Publish to pub.dev
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@v3

# Install Flutter
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.10'

# Setup Dart SDK
- uses: dart-lang/setup-dart@v1

# Setup Dependencies
- uses: ./.github/actions/dependencies

# Publish
- name: Check Publish Warnings
shell: bash
run: flutter pub publish --dry-run
- name: Publish Package
shell: bash
run: flutter pub publish -f

0 comments on commit 2a37693

Please sign in to comment.