Skip to content

Commit

Permalink
Use argocd-commenter-test-fixture repository for e2e test (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
int128 authored Sep 26, 2021
1 parent c3a3d74 commit 924a19a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 29 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,20 @@ jobs:
steps:
- uses: actions/checkout@v2

# deploy Argo CD
- run: git config user.name ci
- run: git config user.email [email protected]
# set up fixture
- uses: cybozu/octoken-action@v1
id: octoken
with:
github_app_id: ${{ secrets.E2E_SETUP_GITHUB_APP_ID }}
github_app_private_key: ${{ secrets.E2E_SETUP_GITHUB_APP_PRIVATE_KEY }}
- uses: actions/checkout@v2
with:
repository: int128/argocd-commenter-e2e-test
path: e2e_test/argocd-commenter-e2e-test
token: ${{ steps.octoken.outputs.token }}
- run: make -C e2e_test setup-fixture

# deploy Argo CD
- run: make -C e2e_test cluster
- run: make -C e2e_test deploy-argocd

Expand Down Expand Up @@ -99,15 +109,13 @@ jobs:
env:
PULL_REQUEST_BODY: "e2e-test #${{ github.event.pull_request.number }}"
DEPLOYMENT_URL: ${{ steps.deployment-app1.outputs.url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.octoken.outputs.token }}
- run: make -C e2e_test test2
env:
PULL_REQUEST_BODY: "e2e-test #${{ github.event.pull_request.number }}"
DEPLOYMENT_URL: ${{ steps.deployment-app2.outputs.url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.octoken.outputs.token }}

- run: make -C e2e_test cleanup-fixture
if: always()
- run: make -C e2e_test logs-argocd
if: always()
- run: make -C e2e_test logs-controller
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ bin

# e2e test
/e2e_test/output/
/e2e_test/argocd-commenter-e2e-test/
15 changes: 7 additions & 8 deletions e2e_test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ KUBECONFIG := output/kubeconfig.yaml
export KUBECONFIG

GITHUB_RUN_NUMBER ?= 0
FIXTURE_BRANCH := e2e-test-$(GITHUB_RUN_NUMBER)
FIXTURE_BRANCH := e2e-test/$(GITHUB_RUN_NUMBER)
export FIXTURE_BRANCH

all:
Expand All @@ -21,7 +21,7 @@ deploy: deploy-argocd deploy-controller

deploy-argocd: cluster
kustomize build argocd | kubectl apply -f -
kustomize build applications | sed -e "s/FIXTURE_BRANCH/$(FIXTURE_BRANCH)/g" | kubectl apply -f -
kustomize build applications | sed -e "s|FIXTURE_BRANCH|$(FIXTURE_BRANCH)|g" | kubectl apply -f -

deploy-controller: cluster
cd controller && kustomize edit set image controller="$(CONTROLLER_IMAGE)"
Expand All @@ -39,21 +39,20 @@ undeploy:

# fixture
setup-fixture:
$(MAKE) -C fixture setup
test -d argocd-commenter-e2e-test
rsync -av fixture/ argocd-commenter-e2e-test/
$(MAKE) -C argocd-commenter-e2e-test setup

test1:
kubectl -n argocd annotate application app1 'argocd-commenter.int128.github.io/deployment-url=$(DEPLOYMENT_URL)'
$(MAKE) -C fixture test1
$(MAKE) -C argocd-commenter-e2e-test test1
./wait-for-sync-status.sh app1 $(FIXTURE_BRANCH)/main Synced Succeeded Healthy

test2:
kubectl -n argocd annotate application app2 'argocd-commenter.int128.github.io/deployment-url=$(DEPLOYMENT_URL)'
$(MAKE) -C fixture test2
$(MAKE) -C argocd-commenter-e2e-test test2
./wait-for-sync-status.sh app2 $(FIXTURE_BRANCH)/main OutOfSync Failed Healthy

cleanup-fixture:
$(MAKE) -C fixture cleanup

logs-controller:
-kubectl -n argocd-commenter-system logs -l control-plane=controller-manager --all-containers --tail=-1
logs-argocd:
Expand Down
4 changes: 2 additions & 2 deletions e2e_test/applications/app1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ metadata:
spec:
project: default
source:
repoURL: https://github.com/int128/argocd-commenter
repoURL: https://github.com/int128/argocd-commenter-e2e-test
targetRevision: FIXTURE_BRANCH/main
path: e2e_test/fixture/app1
path: app1
destination:
server: https://kubernetes.default.svc
namespace: app1
Expand Down
4 changes: 2 additions & 2 deletions e2e_test/applications/app2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ metadata:
spec:
project: default
source:
repoURL: https://github.com/int128/argocd-commenter
repoURL: https://github.com/int128/argocd-commenter-e2e-test
targetRevision: FIXTURE_BRANCH/main
path: e2e_test/fixture/app2
path: app2
destination:
server: https://kubernetes.default.svc
namespace: test2-fixture
Expand Down
16 changes: 7 additions & 9 deletions e2e_test/fixture/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
all:

setup:
git checkout --orphan "$(FIXTURE_BRANCH)/main"
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git checkout -B "$(FIXTURE_BRANCH)/main"
git add .
git commit -a -m "Initial commit"
git push origin "$(FIXTURE_BRANCH)/main"
git push origin -f "$(FIXTURE_BRANCH)/main"

test1:
git checkout "$(FIXTURE_BRANCH)/main"
git checkout -b "$(FIXTURE_BRANCH)/test1"
sed -i -e 's/name: echoserver/name: echoserver-test1/g' app1/deployment/echoserver.yaml
git commit -a -m 'e2e-test: app1'
git push origin "$(FIXTURE_BRANCH)/test1"
git push origin -f "$(FIXTURE_BRANCH)/test1"
gh pr create --base "$(FIXTURE_BRANCH)/main" --fill --body "$(PULL_REQUEST_BODY)" --label e2e-test
gh pr merge --squash
git checkout "$(FIXTURE_BRANCH)/main"
Expand All @@ -21,13 +24,8 @@ test2:
git checkout -b "$(FIXTURE_BRANCH)/test2"
sed -i -e 's/app: echoserver/app: echoserver-test2/g' app2/deployment/echoserver.yaml
git commit -a -m 'e2e-test: app2'
git push origin "$(FIXTURE_BRANCH)/test2"
git push origin -f "$(FIXTURE_BRANCH)/test2"
gh pr create --base "$(FIXTURE_BRANCH)/main" --fill --body "$(PULL_REQUEST_BODY)" --label e2e-test
gh pr merge --squash
git checkout "$(FIXTURE_BRANCH)/main"
git pull origin "$(FIXTURE_BRANCH)/main" --ff-only

cleanup:
-git push origin --delete "$(FIXTURE_BRANCH)/main"
-git push origin --delete "$(FIXTURE_BRANCH)/test1"
-git push origin --delete "$(FIXTURE_BRANCH)/test2"
2 changes: 1 addition & 1 deletion e2e_test/wait-for-sync-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eu

application_name="$1"
want_branch="$2"
want_revision="$(git rev-parse "$want_branch")"
want_revision="$(git -C argocd-commenter-e2e-test rev-parse "$want_branch")"
want_sync_status="$3"
want_phase="$4"
want_health_status="$5"
Expand Down

0 comments on commit 924a19a

Please sign in to comment.