Merge pull request #288 from focustree/package-tutorial #40
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: CD | |
on: | |
push: | |
branches: [main] | |
env: | |
WORK_DIR: packages/starknet | |
jobs: | |
dump-context: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Dump job context | |
env: | |
JOB_CONTEXT: ${{ toJson(job) }} | |
run: echo "$JOB_CONTEXT" | |
- name: Dump steps context | |
env: | |
STEPS_CONTEXT: ${{ toJson(steps) }} | |
run: echo "$STEPS_CONTEXT" | |
- name: Dump runner context | |
env: | |
RUNNER_CONTEXT: ${{ toJson(runner) }} | |
run: echo "$RUNNER_CONTEXT" | |
- name: Dump strategy context | |
env: | |
STRATEGY_CONTEXT: ${{ toJson(strategy) }} | |
run: echo "$STRATEGY_CONTEXT" | |
- name: Dump matrix context | |
env: | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
run: echo "$MATRIX_CONTEXT" | |
- name: Show default environment variables | |
run: | | |
echo "The job_id is: $GITHUB_JOB" # reference the default environment variables | |
echo "The id of this action is: $GITHUB_ACTION" # reference the default environment variables | |
echo "The run id is: $GITHUB_RUN_ID" | |
echo "The GitHub Actor's username is: $GITHUB_ACTOR" | |
echo "GitHub SHA: $GITHUB_SHA" | |
# Check code formatting and static analysis on a single OS (linux) | |
# against dev, stable, and 2.17.3 (the package's lower bound). | |
analyze: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
sdk: [dev, stable, 2.17.3] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dart-lang/setup-dart@v1.0 | |
with: | |
sdk: ${{ matrix.sdk }} | |
- id: install | |
name: Install dependencies | |
run: dart pub get | |
working-directory: ${{ env.WORK_DIR }} | |
- name: Check formatting | |
run: dart format --output=none --set-exit-if-changed . | |
if: matrix.sdk == 'dev' && steps.install.outcome == 'success' | |
working-directory: ${{ env.WORK_DIR }} | |
- name: Analyze code | |
run: dart analyze --fatal-infos | |
if: always() && steps.install.outcome == 'success' | |
working-directory: ${{ env.WORK_DIR }} | |
# Run tests on a matrix consisting of two dimensions: | |
# 1. OS: ubuntu-latest | |
# 2. Release channel: dev, stable, and 2.17.3 (the package's lower bound) | |
test: | |
needs: analyze | |
defaults: | |
run: | |
working-directory: ${{ env.WORK_DIR }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
sdk: [dev, stable, 2.17.3] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dart-lang/setup-dart@v1.0 | |
with: | |
sdk: ${{ matrix.sdk }} | |
- id: install | |
name: Install dependencies | |
run: dart pub get | |
- name: Run tests | |
run: dart test | |
if: always() && steps.install.outcome == 'success' | |
- name: Run Chrome tests | |
run: dart test --platform chrome | |
if: always() && steps.install.outcome == 'success' | |
package-analysis: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ${{ env.WORK_DIR }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: axel-op/dart-package-analyzer@v3 | |
with: | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
relativePath: ${{ env.WORK_DIR }} | |
publish: | |
if: github.event.pull_request.head.repo.fork == false | |
needs: test | |
defaults: | |
run: | |
working-directory: ${{ env.WORK_DIR }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v2 | |
# Only publishes if package version is different from the latest published on pub.dev | |
# See the docs: https://github.com/marketplace/actions/dart-and-flutter-package-publisher | |
- name: "Publish package" | |
uses: k-paxian/dart-package-publisher@master | |
with: | |
accessToken: ${{ secrets.OAUTH_ACCESS_TOKEN }} | |
refreshToken: ${{ secrets.OAUTH_REFRESH_TOKEN }} | |
skipTests: true # Tests have already been run before | |
relativePath: ${{ env.WORK_DIR }} |