refactor: Update PORT environment variable in tests.yml #276
Workflow file for this run
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: Checkout | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "main" | |
- "master" | |
- "dev" | |
- "develop" | |
- "feature/**" | |
- "bugfix/**" | |
- "hotfix/**" | |
- "support/**" | |
paths: | |
- "lib/**.dart" | |
- "test/**.dart" | |
- "example/**.dart" | |
- .github/workflows/*.yml | |
- "pubspec.yaml" | |
jobs: | |
checkout: | |
name: "Checkout" | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./ | |
container: | |
image: dart:stable | |
env: | |
pub-cache-name: pub | |
timeout-minutes: 10 | |
steps: | |
- name: 🚂 Get latest code | |
id: checkout | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
.github | |
pubspec.yaml | |
lib | |
test | |
analysis_options.yaml | |
CHANGELOG.md | |
- name: 📤 Restore Pub modules | |
id: cache-pub-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
$PWD/.pub_cache/ | |
key: ${{ runner.os }}-spinify-${{ env.pub-cache-name }}-${{ hashFiles('**/pubspec.yaml') }} | |
- name: 🗄️ Export Pub cache directory | |
id: export-pub-cache | |
timeout-minutes: 1 | |
run: | | |
export PUB_CACHE=$PWD/.pub_cache/ | |
export PATH="$PATH":"$HOME/.pub-cache/bin" | |
- name: 👷 Install Dependencies | |
id: install-dependencies | |
timeout-minutes: 1 | |
run: dart pub get --no-example | |
- name: 📥 Save Pub modules | |
id: cache-pub-save | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
$PWD/.pub_cache/ | |
key: ${{ runner.os }}-spinify-${{ env.pub-cache-name }}-${{ hashFiles('**/pubspec.yaml') }} | |
- name: 🔎 Check format | |
id: check-format | |
timeout-minutes: 1 | |
run: dart format --set-exit-if-changed -l 80 -o none lib/ | |
- name: 📈 Check analyzer | |
id: check-analyzer | |
timeout-minutes: 1 | |
run: dart analyze --fatal-infos --fatal-warnings lib/ | |
- name: 👀 Verify versions | |
id: verify-versions | |
timeout-minutes: 1 | |
run: | | |
test -f pubspec.yaml && test -f lib/src/model/pubspec.yaml.g.dart | |
version_pubspec=$(grep '^version:' pubspec.yaml | awk '{print $2}' | sed 's/[^[:print:]]//g') | |
version_dart=$(grep 'representation: r' lib/src/model/pubspec.yaml.g.dart | awk -F"'" '{print $2}' | sed 's/[^[:print:]]//g') | |
test -n "$version_pubspec" && test -n "$version_dart" | |
echo "Version from pubspec.yaml: '$version_pubspec'" | |
echo "Version from pubspec.yaml.g.dart: '$version_dart'" | |
echo "$version_pubspec" > /tmp/version_pubspec | |
echo "$version_dart" > /tmp/version_dart | |
diff /tmp/version_pubspec /tmp/version_dart | |
- name: 🧪 Run unit tests | |
id: run-unit-tests | |
timeout-minutes: 2 | |
run: | | |
dart test --color --platform=vm --concurrency=12 \ | |
--timeout=60s --reporter=github --file-reporter=json:coverage/tests.json \ | |
--coverage=coverage -- test/unit_test.dart |