From 0e54e73bb5aa1a65e093ea739f068bb6b24a5128 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 3 Mar 2021 21:15:03 +0100 Subject: [PATCH] Add .circleci/config.yml --- .circleci/config.yml | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..1d65b2a --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,90 @@ +# Author @mvxt +version: 2.1 + +# Simple YAML anchors +aliases: + - &project_dir "~/project" + +commands: + dependencies: + description: "Download dependencies and setup global packages" + parameters: + shell: + type: string + default: "/bin/bash --login -eo pipefail" + pub-cache: + type: string + default: "~/.pub-cache" + steps: + - checkout + - restore_cache: + keys: + - v1.4-dependencies-{{ arch }}-{{ checksum "pubspec.lock" }} + - v1.4-dependencies-{{ arch }}- + - run: + name: Download deps + shell: << parameters.shell >> + command: pub get + - run: + name: Get junitreporter + shell: << parameters.shell >> + command: pub global activate junitreport + - save_cache: + key: v1.4-dependencies-{{ arch }}-{{ checksum "pubspec.lock" }} + paths: + - .dart_tool + - << parameters.pub-cache >> + +###### ################ +# Workflow definition +###### ################ +workflows: + version: 2.1 + test-and-build: + jobs: + - test + - build-linux: + requires: + - test +################## +# Job Definitions +################## +jobs: + test: + docker: + - image: google/dart:2.9.1 + auth: + username: $DOCKER_USERNAME + password: $DOCKER_PASSWORD # context / project UI env-var reference + steps: + - dependencies: + shell: "/bin/bash -eo pipefail" + - run: + name: Make folder for test results + command: mkdir -p test-results/dart-tests + - run: + name: Run tests + command: pub run test --reporter json | tojunit --output test-results/dart-tests/circleci_dart_demo_test-report.xml + - store_test_results: + path: test-results + + build-linux: + machine: true + steps: + - run: + name: Install Dart SDK + shell: /bin/bash --login -eo pipefail + command: | + # Setup repo & signing key + sudo apt update + sudo apt install apt-transport-https + sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' + sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list' + + # Update again and install + sudo apt update + sudo apt install dart + + # Set PATH in profile for downstream commands + echo "export PATH=$PATH:/usr/lib/dart/bin" >> $BASH_ENV + - dependencies \ No newline at end of file