From 5d2f25b3ca456bb16065144fc69b53a0b50fba6f Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 15 Dec 2023 13:03:30 -0800 Subject: [PATCH] Updated GitHub and GitLab workflows --- .github/workflows/dart.yml | 2 +- .gitlab-ci.yml | 94 +++++++++++++++++++++++++++++++++----- 2 files changed, 84 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index b0abb61..f4ee33a 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -24,7 +24,7 @@ jobs: run: | dart test --coverage=coverage dart run coverage:format_coverage --lcov --in=coverage \ - -out=coverage/lcov.info --packages=.packages --report-on=lib,bin + -out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=lib,bin - uses: codecov/codecov-action@v2 name: Publish coverage to Codecov diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 110aa8c..875382a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,19 +1,91 @@ -image: google/dart +# You can copy and paste this template into a new `.gitlab-ci.yml` file. +# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. +# +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Dart.gitlab-ci.yml + +# https://hub.docker.com/_/dart +image: dart:stable variables: + # To learn more go to https://dart.dev/tools/dart-test + # Or run `dart test --help` PUB_VARS: "--platform vm --timeout 30s --concurrency=6 --test-randomize-ordering-seed=random --reporter=expanded" +.use-pub-cache-bin: + # Define commands that need to be executed before each job. + before_script: + # Set PUB_CACHE either here or in the CI/CD Settings if you have multiple jobs that use dart commands. + # PUB_CACHE is used by the `dart pub` command, it needs to be set so package dependencies are stored at the project-level for CI/CD operations. + - export PUB_CACHE=".pub-cache" + - export PATH="$PATH:$HOME/$PUB_CACHE/bin" + +# Cache generated files and plugins between builds. +.upload-cache: + cache: + when: 'on_success' + paths: + - .pub-cache/bin/ + - .pub-cache/global_packages/ + - .pub-cache/hosted/ + - .dart_tool/ + - .packages + # Cache downloaded dependencies and plugins between builds. # To keep cache across branches add 'key: "$CI_JOB_NAME"' -cache: - paths: - - .pub-cache/global_packages +.download-cache: + cache: + paths: + - .dart_tool/ + - .packages + policy: pull -before_script: - - export PATH="$PATH":"~/.pub-cache/bin" - - pub get --no-precompile - -test: - stage: test +install-dependencies: + stage: .pre + extends: + - .use-pub-cache-bin + - .upload-cache script: - - pub run test $PUB_VARS + - dart pub get --no-precompile + +build: + stage: build + needs: + - install-dependencies + extends: + - .use-pub-cache-bin + - .upload-cache + script: + - dart pub get --offline --precompile + +unit-test: + stage: test + needs: + - build + extends: + - .use-pub-cache-bin + - .download-cache + script: + - dart test $PUB_VARS + +lint-test: + stage: test + needs: + - install-dependencies + extends: + - .use-pub-cache-bin + - .download-cache + script: + - dart analyze . + +format-test: + stage: test + needs: + - install-dependencies + extends: + - .use-pub-cache-bin + - .download-cache + script: + - dart format --set-exit-if-changed bin/ lib/ test/ \ No newline at end of file