From 3b3f58d9df1d7e4f1894e9753975a53c5f62b1ee Mon Sep 17 00:00:00 2001 From: The one with the braid Date: Thu, 11 Jul 2024 11:52:38 +0200 Subject: [PATCH] chore: add CI Signed-off-by: The one with the braid --- .gitlab-ci.yml | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..6eede8b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,79 @@ +variables: + FLUTTER_VERSION: 3.22.2 + +image: registry.gitlab.com/theonewiththebraid/flutter-dockerimages:${FLUTTER_VERSION}-base + +stages: + - coverage + - deploy + - publish + +workflow: + rules: + - if: $CI_MERGE_REQUEST_IID + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +code_analyze: + stage: coverage + dependencies: [] + script: + - dart pub get + - dart format lib test example --set-exit-if-changed + - dart analyze + - dart run import_sorter:main --no-comments --exit-if-changed + + +dart_test: + stage: coverage + image: dart + dependencies: [ + code_analyze + ] + script: + - dart pub get + - dart test + +code_quality: + stage: coverage + image: dart + before_script: + - dart pub global activate dart_code_metrics + script: + - dart pub global run dart_code_metrics:metrics analyze lib -r gitlab > code-quality-report.json + artifacts: + reports: + codequality: code-quality-report.json + # also create an actual artifact for inspection purposes + paths: + - code-quality-report.json + +dry-run: + stage: publish + image: dart + script: + - rm -rf ./docs + - dart pub get + - dart pub publish --dry-run + +pub-dev: + stage: publish + image: dart + dependencies: [ + dry-run + ] + script: + - rm -rf ./docs + - | + if [ -z "${PUB_DEV_CREDENTIALS}" ]; then + echo "Missing PUB_DEV_CREDENTIALS environment variable" + exit 1 + fi + + mkdir -p ~/.config/dart + cp "${PUB_DEV_CREDENTIALS}" ~/.config/dart/pub-credentials.json + + - dart pub get + - dart pub publish --force + rules: + - if: $CI_COMMIT_TAG