diff --git a/.circleci/config.yml b/.circleci/config.yml index a1d1e83..fd4888b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ workflows: branches: ignore: - master - - test: + - publish_dev: requires: - validate filters: @@ -23,6 +23,14 @@ workflows: only: - staging - trying + - test: + requires: + - publish_dev + filters: + branches: + only: + - staging + - trying - publish: requires: - test @@ -39,7 +47,7 @@ jobs: - checkout - install-circleci - pack-and-validate - test: + publish_dev: docker: - image: cimg/base:2019.08 working_directory: ~/repo @@ -56,11 +64,24 @@ jobs: echo "export ORB_VERSION=\"${ORB_VERSION}\"" >> $BASH_ENV echo $ORB_VERSION echo "export PR_MESSAGE=\"BotComment: *Development* version of orb available for manual validation - \\\`${ORB_VERSION}\\\`\"" >> $BASH_ENV + + test: + docker: + - image: cimg/base:2019.08 + working_directory: ~/repo + parallelism: 4 + steps: + - checkout + - install-circleci + - pack-and-validate + - pr-info - install-bats - run: name: Import Tests using BATS command: | export BATS_IMPORT_DEV_ORB="eddiewebb/<>@dev:${PR_NUMBER}" + export BATS_TEST_LIST=$(bats -l test | circleci tests split | tr '\n' ' ') + echo "This node will run ${BATS_TEST_LIST}" bats test - pr-comment @@ -101,7 +122,8 @@ commands: - run: name: Install BATS (bash testing) command: | - cd /tmp && git clone https://github.com/bats-core/bats-core.git && cd bats-core + # my fork includes tets list for splitting + cd /tmp && git clone https://github.com/eddiewebb/bats-core.git && cd bats-core ./install.sh /usr/local - run: name: Install YQ diff --git a/test/test_expansion.bats b/test/test_expansion.bats index 99ab84d..f7509b7 100755 --- a/test/test_expansion.bats +++ b/test/test_expansion.bats @@ -50,6 +50,28 @@ function setup { } +@test "Default job sets block workflow properly" { + # given + process_config_with test/inputs/fulljob.yml + + # when + assert_jq_match '.jobs | length' 1 #only 1 job + assert_jq_match '.jobs["Single File"].steps | length' 1 #only 1 steps + + jq -r '.jobs["Single File"].steps[0].run.command' $JSON_PROJECT_CONFIG > ${BATS_TMPDIR}/script-${BATS_TEST_NUMBER}.bash + + export CIRCLECI_API_KEY="madethisup" + export CIRCLE_BUILD_NUM="2" + export CIRCLE_JOB="singlejob" + export CIRCLE_PROJECT_USERNAME="madethisup" + export CIRCLE_PROJECT_REPONAME="madethisup" + export CIRCLE_REPOSITORY_URL="madethisup" + export CIRCLE_BRANCH="madethisup" + + run bash ${BATS_TMPDIR}/script-${BATS_TEST_NUMBER}.bash + assert_contains_text "Orb parameter block-workflow is true." +} + # See https://github.com/eddiewebb/circleci-queue/issues/26 for explanation of race condition @test "Race condition on previous workflow does not fool us" {