Skip to content

Commit

Permalink
refactor: e2e test ensure conftest command to check conftest version …
Browse files Browse the repository at this point in the history
…is greater or equal to specific version
  • Loading branch information
krrrr38 committed Dec 18, 2022
1 parent b6f3724 commit edd505e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
test:
docker:
- image: ghcr.io/runatlantis/testing-env:2022.11.17
- image: ghcr.io/runatlantis/testing-env:2022.12.17
steps:
- checkout
- run: make check-fmt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
if: github.event.pull_request.draft == false
name: runner / gotest
runs-on: ubuntu-22.04
container: ghcr.io/runatlantis/testing-env:2022.11.17
container: ghcr.io/runatlantis/testing-env:2022.12.17
steps:
- uses: actions/[email protected]
- run: make test-all
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ test: ## Run tests

.PHONY: docker/test
docker/test: ## Run tests in docker
docker run -it -v $(pwd):/atlantis ghcr.io/runatlantis/testing-env:2022.11.17 sh -c "cd /atlantis && make test"
docker run -it -v $(pwd):/atlantis ghcr.io/runatlantis/testing-env:2022.12.17 sh -c "cd /atlantis && make test"

test-all: ## Run tests including integration
@go test $(PKG)

.PHONY: docker/test-all
docker/test-all: ## Run all tests in docker
docker run -it -v $(pwd):/atlantis ghcr.io/runatlantis/testing-env:2022.11.17 sh -c "cd /atlantis && make test-all"
docker run -it -v $(pwd):/atlantis ghcr.io/runatlantis/testing-env:2022.12.17 sh -c "cd /atlantis && make test-all"

test-coverage:
@mkdir -p .cover
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) {
}
// Ensure we have >= TF 0.14 locally.
ensureRunning014(t)
// Ensure we have >= Conftest 0.21 locally.
// Ensure we have conftest locally.
ensureRunningConftest(t)

cases := []struct {
Expand Down Expand Up @@ -1365,9 +1365,9 @@ func mkSubDirs(t *testing.T) (string, string, string) {

// Will fail test if conftest isn't in path and isn't version >= 0.25.0
func ensureRunningConftest(t *testing.T) {
localPath, err := exec.LookPath(fmt.Sprintf("conftest%s", ConftestVersion))
localPath, err := exec.LookPath("conftest")
if err != nil {
t.Logf("conftest >= %s must be installed to run this test", ConftestVersion)
t.Logf("conftest must be installed to run this test")
t.FailNow()
}
versionOutBytes, err := exec.Command(localPath, "--version").Output() // #nosec
Expand Down
2 changes: 0 additions & 2 deletions testing/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ RUN case $(uname -m) in x86_64|amd64) ARCH="x86_64" ;; aarch64|arm64|armv7l) ARC
sed -n "/conftest_${CONFTEST_VERSION}_Linux_${ARCH}.tar.gz/p" checksums.txt | sha256sum -c && \
mkdir -p /usr/local/bin/cft/versions/${CONFTEST_VERSION} && \
tar -C /usr/local/bin/cft/versions/${CONFTEST_VERSION} -xzf conftest_${CONFTEST_VERSION}_Linux_${ARCH}.tar.gz && \
# After migrating e2e test which use contest command instead of contest$version, you can remove contest$version command.
ln -s /usr/local/bin/cft/versions/${CONFTEST_VERSION}/conftest /usr/local/bin/conftest${CONFTEST_VERSION} && \
ln -s /usr/local/bin/cft/versions/${CONFTEST_VERSION}/conftest /usr/local/bin/conftest && \
rm conftest_${CONFTEST_VERSION}_Linux_${ARCH}.tar.gz && \
rm checksums.txt
Expand Down

0 comments on commit edd505e

Please sign in to comment.