Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Sep 19, 2023
1 parent 2dc7a03 commit 58585ac
Show file tree
Hide file tree
Showing 34 changed files with 771 additions and 418 deletions.
36 changes: 36 additions & 0 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Prepare"
description: "Prepare and tests the project"

inputs:
sdk-version:
description: "Dart SDK version"
required: false
default: "stable"

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk-version }}

- name: Cache Dart dependencies
uses: actions/cache@v3
with:
path: "~/.pub-cache"
key: ${{ runner.os }}-dart-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-dart-
- name: Get dependencies
run: dart pub get
shell: bash

- name: Build version
run: ./scripts/build_version.dart
shell: bash

- name: Analyze
run: dart analyze --fatal-infos --fatal-warnings .
shell: bash
13 changes: 13 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Test Step"
description: "Tests the project"

runs:
using: "composite"
steps:
- name: Generate git cache
run: ./bin/fvm.dart install master
shell: bash

- name: Run tests
run: dart test
shell: bash
42 changes: 0 additions & 42 deletions .github/workflows/common.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/deploy_chocolatey.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/deploy_docker.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Build
run: |
yarn
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/deploy_homebrew.yml

This file was deleted.

70 changes: 63 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,79 @@ on:
types: [published, released]

jobs:
common:
uses: ./.github/workflows/common.yml
test:
name: Test
uses: ./.github/workflows/test.yml

release:
name: Release
needs: common
needs: test
runs-on: ubuntu-latest
env:
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/[email protected]

- run: dart pub get
- name: Prepare environment
uses: ./.github/actions/prepare/action.yml

- name: Deploy Github
run: dart pub run grinder pkg-github-all

- name: Deploy to Pub
run: dart pub run grinder pkg-pub-deploy

deploy-windows:
name: Cholatey Deploy (Windows)
needs: release
runs-on: windows-latest
env:
CHOCOLATEY_TOKEN: ${{ secrets.CHOCOLATEY_TOKEN }}
steps:
- name: Prepare environment
uses: ./.github/actions/prepare/action.yml

- name: Deploy Chocolatey (Windows)
run: dart pub run grinder pkg-chocolatey-deploy

deploy-homebrew:
name: Deploy Homebrew
runs-on: ubuntu-latest
needs: release
env:
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }}
GITHUB_TOKEN: ${{ secrets.HOMEBREW_FVM_GH_TOKEN }}

steps:
- name: Prepare environment
uses: ./.github/actions/prepare/action.yml

- name: Deploy to Homebrew
run: dart pub run grinder pkg-homebrew-update

deploy-docker:
name: Docker Deploy (latest)
runs-on: ubuntu-latest
needs: release
steps:
- name: Prepare environment
uses: ./.github/actions/prepare/action.yml

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push (latest)
id: docker_build_latest
uses: docker/build-push-action@v5
with:
file: ./.docker/Dockerfile
push: true
tags: leoafarias/fvm:{{ github.event.release.tag_name }}
23 changes: 22 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Test CLI

on:
workflow_call:
inputs:
sdk-version:
description: "Dart SDK version"
type: string
required: false
default: "stable"

pull_request:
paths-ignore:
- "website/**"
Expand All @@ -13,4 +21,17 @@ concurrency:

jobs:
test:
uses: ./.github/workflows/common.yml
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- name: Prepare environment
uses: ./.github/actions/prepare/action.yml
with:
sdk-version: ${{ github.event.inputs.sdk-version }}

- name: Tests
uses: ./.github/actions/test/action.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ test/support_assets/dart_package/lib/src/version.dart
.fvm/versions
coverage/test
.failed_tracker
coverage/html
Loading

0 comments on commit 58585ac

Please sign in to comment.