<commit_before>package git_pipeline_test

import (
	"time"

	"github.com/concourse/testflight/guidserver"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("A pipeline with git resources", func() {
	It("triggers when the repo changes", func() {
		By("building the initial commit")
		guid1 := gitServer.Commit()
		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement(guid1))

		By("building another commit")
		guid2 := gitServer.Commit()
		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement(guid2))
	})

	It("performs output conditions correctly", func() {
		By("executing the build when a commit is made")
		committedGuid := gitServer.Commit()
		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement(committedGuid))

		masterSHA := gitServer.RevParse("master")
		Ω(masterSHA).ShouldNot(BeEmpty())

		By("performing on: [success] outputs on success")
		Eventually(func() string {
			return successGitServer.RevParse("success")
		}, 30*time.Second, 1*time.Second).Should(Equal(masterSHA))

		By("performing on: [failure] outputs on failure")
		Eventually(func() string {
			return failureGitServer.RevParse("failure")
		}, 30*time.Second, 1*time.Second).Should(Equal(masterSHA))

		By("not performing on: [success] outputs on failure")
		Consistently(func() string {
			return noUpdateGitServer.RevParse("no-update")
		}, 10*time.Second, 1*time.Second).Should(BeEmpty())

		By("always performs ensure on: [success]")
		Consistently(func() string {
			return ensureSuccessGitServer.RevParse("ensure-success")
		}, 10*time.Second, 1*time.Second).Should(Equal(masterSHA))

		By("always performs ensure on: [failure]")
		Consistently(func() string {
			return ensureFailureGitServer.RevParse("ensure-failure")
		}, 10*time.Second, 1*time.Second).Should(Equal(masterSHA))
	})

	It("performs build matrixes correctly", func() {
		By("executing the build when a commit is made")
		committedGuid := gitServer.Commit()

		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement("passing-unit-1/file passing-unit-2/file " + committedGuid))

		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement("failed " + committedGuid))
	})
})
<commit_msg>fix race: use Eventually to wait for ensure hooks<commit_after>package git_pipeline_test

import (
	"time"

	"github.com/concourse/testflight/guidserver"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("A pipeline with git resources", func() {
	It("triggers when the repo changes", func() {
		By("building the initial commit")
		guid1 := gitServer.Commit()
		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement(guid1))

		By("building another commit")
		guid2 := gitServer.Commit()
		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement(guid2))
	})

	It("performs output conditions correctly", func() {
		By("executing the build when a commit is made")
		committedGuid := gitServer.Commit()
		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement(committedGuid))

		masterSHA := gitServer.RevParse("master")
		Ω(masterSHA).ShouldNot(BeEmpty())

		By("performing on: [success] outputs on success")
		Eventually(func() string {
			return successGitServer.RevParse("success")
		}, 30*time.Second, 1*time.Second).Should(Equal(masterSHA))

		By("performing on: [failure] outputs on failure")
		Eventually(func() string {
			return failureGitServer.RevParse("failure")
		}, 30*time.Second, 1*time.Second).Should(Equal(masterSHA))

		By("not performing on: [success] outputs on failure")
		Consistently(func() string {
			return noUpdateGitServer.RevParse("no-update")
		}, 10*time.Second, 1*time.Second).Should(BeEmpty())

		By("always performs ensure on: [success]")
		Eventually(func() string {
			return ensureSuccessGitServer.RevParse("ensure-success")
		}, 30*time.Second, 1*time.Second).Should(Equal(masterSHA))

		By("always performs ensure on: [failure]")
		Eventually(func() string {
			return ensureFailureGitServer.RevParse("ensure-failure")
		}, 30*time.Second, 1*time.Second).Should(Equal(masterSHA))
	})

	It("performs build matrixes correctly", func() {
		By("executing the build when a commit is made")
		committedGuid := gitServer.Commit()

		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement("passing-unit-1/file passing-unit-2/file " + committedGuid))

		Eventually(guidserver.ReportingGuids, 5*time.Minute, 10*time.Second).Should(ContainElement("failed " + committedGuid))
	})
})

{'fraction_non_alphanumeric': 0.14506565014824227, 'fraction_numerical': 0.015247776365946633, 'mean_word_length': 5.854862119013062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7036501', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1493, 'n_words': 290}