Skip to content

Commit

Permalink
chore: cherry-pick #4576 (e2e update) into release-0.27 (release-0.27) (
Browse files Browse the repository at this point in the history
#4607)

Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
chenrui333 authored May 27, 2024
1 parent 0a73661 commit a2b1451
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 79 deletions.
30 changes: 0 additions & 30 deletions .circleci/config.yml

This file was deleted.

48 changes: 43 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: changes
with:
filters: |
Expand All @@ -41,12 +41,12 @@ jobs:
if: needs.changes.outputs.should-run-tests == 'true'
name: Tests
runs-on: ubuntu-22.04
container: ghcr.io/runatlantis/testing-env:latest
container: ghcr.io/runatlantis/testing-env:latest@sha256:346fd2028603d7c9369f709023ef993faf60a70ef4c91963f5baa7454196df32
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4

# need to setup go toolchain explicitly
- uses: actions/setup-go@v5
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5
with:
go-version-file: go.mod

Expand Down Expand Up @@ -100,3 +100,41 @@ jobs:
runs-on: ubuntu-22.04
steps:
- run: 'echo "No build required"'

e2e-github:
runs-on: ubuntu-latest
# dont run e2e tests on forked PRs
if: github.event.pull_request.head.repo.fork == false
env:
TERRAFORM_VERSION: 1.8.3
ATLANTISBOT_GITHUB_USERNAME: ${{ secrets.ATLANTISBOT_GITHUB_USERNAME }}
ATLANTISBOT_GITHUB_TOKEN: ${{ secrets.ATLANTISBOT_GITHUB_TOKEN }}
NGROK_AUTH_TOKEN: ${{ secrets.ATLANTISBOT_NGROK_AUTH_TOKEN }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5
with:
go-version-file: go.mod

# This version of TF will be downloaded before Atlantis is started.
# We do this instead of setting --default-tf-version because setting
# that flag starts the download asynchronously so we'd have a race
# condition.
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}

- name: Setup ngrok
run: |
wget -q -nc https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz
tar -xzf ngrok-v3-stable-linux-amd64.tgz && \
chmod +x ngrok
./ngrok --help
- name: Setup gitconfig
run: |
git config --global user.email "[email protected]"
git config --global user.name "atlantisbot"
- run: |
make build-service
./scripts/e2e.sh
3 changes: 0 additions & 3 deletions e2e/.gitconfig

This file was deleted.

8 changes: 4 additions & 4 deletions e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ type Project struct {

func main() {

githubUsername := os.Getenv("GITHUB_USERNAME")
githubUsername := os.Getenv("ATLANTISBOT_GITHUB_USERNAME")
if githubUsername == "" {
log.Fatalf("GITHUB_USERNAME cannot be empty")
log.Fatalf("ATLANTISBOT_GITHUB_USERNAME cannot be empty")
}
githubToken := os.Getenv("GITHUB_PASSWORD")
githubToken := os.Getenv("ATLANTISBOT_GITHUB_TOKEN")
if githubToken == "" {
log.Fatalf("GITHUB_PASSWORD cannot be empty")
log.Fatalf("ATLANTISBOT_GITHUB_TOKEN cannot be empty")
}
atlantisURL := os.Getenv("ATLANTIS_URL")
if atlantisURL == "" {
Expand Down
28 changes: 0 additions & 28 deletions scripts/e2e-deps.sh

This file was deleted.

14 changes: 5 additions & 9 deletions scripts/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
set -euo pipefail
IFS=$'\n\t'

# download all the tooling needed for e2e tests
CIRCLE_WORKING_DIRECTORY="${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}" # https://discuss.circleci.com/t/circle-working-directory-doesnt-expand/17007/5
${CIRCLE_WORKING_DIRECTORY}/scripts/e2e-deps.sh
cd "${CIRCLE_WORKING_DIRECTORY}/e2e"

# start atlantis server in the background and wait for it to start
./atlantis server \
--gh-user="$GITHUB_USERNAME" \
--gh-token="$GITHUB_PASSWORD" \
--gh-user="$ATLANTISBOT_GITHUB_USERNAME" \
--gh-token="$ATLANTISBOT_GITHUB_TOKEN" \
--data-dir="/tmp" \
--log-level="debug" \
--repo-allowlist="github.com/runatlantis/atlantis-tests" \
Expand All @@ -20,14 +15,15 @@ cd "${CIRCLE_WORKING_DIRECTORY}/e2e"
sleep 2

# start ngrok in the background and wait for it to start
./ngrok config add-authtoken $NGROK_AUTH_TOKEN
./ngrok http 4141 > /tmp/ngrok.log &
./ngrok config add-authtoken $NGROK_AUTH_TOKEN > /dev/null 2>&1
./ngrok http 4141 > /tmp/ngrok.log 2>&1 &
sleep 2

# find out what URL ngrok has given us
export ATLANTIS_URL=$(curl -s 'http://localhost:4040/api/tunnels' | jq -r '.tunnels[] | select(.proto=="https") | .public_url')

# Now we can start the e2e tests
cd "${GITHUB_WORKSPACE:-$(git rev-parse --show-toplevel)}/e2e"
echo "Running 'make build'"
make build

Expand Down

0 comments on commit a2b1451

Please sign in to comment.