Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new dev/test environment #414

Merged
merged 14 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!hcloud/
!internal/
!go.mod
!go.sum
!main.go
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Run tests
run: |
go vet ./...
go test $(go list ./... | grep -v e2etests)
go test $(go list ./... | grep -v e2e)

lint:
name: Lint
Expand Down
63 changes: 24 additions & 39 deletions .github/workflows/test_e2e.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
name: Run e2e tests
on: [ pull_request ]
jobs:
k8s:
runs-on: ubuntu-latest
strategy:
matrix:
k8s: [ 1.24.10, 1.25.6, 1.26.1 ]
fail-fast: false
name: k8s ${{ matrix.k8s }}
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.19'
- uses: actions/checkout@master
- name: HCLOUD_TOKEN
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
TTS_TOKEN: ${{ secrets.TTS_TOKEN }}
run: |
set -ueo pipefail
if [[ "${HCLOUD_TOKEN:-}" != "" ]]; then
echo "HCLOUD_TOKEN=$HCLOUD_TOKEN" >> "$GITHUB_ENV"
elif [[ "${TTS_TOKEN:-}" != "" ]]; then
token="$(./scripts/get-token.sh)"
echo "::add-mask::$token"
echo "HCLOUD_TOKEN=$token" >> "$GITHUB_ENV"
else
echo "::error ::Couldn't determine HCLOUD_TOKEN. Check that repository secrets are setup correctly."
exit 1
fi
- name: Run tests
env:
K8S_VERSION: k8s-${{ matrix.k8s }}
USE_NETWORKS: yes
run: |
go test $(go list ./... | grep e2etests) -v -timeout 60m
./scripts/delete-token.sh $HCLOUD_TOKEN
k3s:
runs-on: ubuntu-latest
strategy:
matrix:
k3s: [ v1.24.10+k3s1, v1.25.6+k3s1, v1.26.1+k3s1 ]
k3s: [ v1.24, v1.25, v1.26 ]
fail-fast: false
name: k3s ${{ matrix.k3s }}
steps:
Expand All @@ -64,10 +29,30 @@ jobs:
echo "::error ::Couldn't determine HCLOUD_TOKEN. Check that repository secrets are setup correctly."
exit 1
fi

- uses: 3bit/setup-hcloud@v2
- uses: yokawasa/[email protected]
with:
setup-tools: |
helm
kubectl
skaffold
helm: v3.11.2
kubectl: v1.26.3
skaffold: v2.3.0

- name: Run tests
env:
K8S_VERSION: k3s-${{ matrix.k3s }}
K3S_CHANNEL: ${{ matrix.k3s }}
SCOPE: gha-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.k3s }}
USE_NETWORKS: yes
samcday marked this conversation as resolved.
Show resolved Hide resolved
run: |
go test $(go list ./... | grep e2etests) -v -timeout 60m
./scripts/delete-token.sh $HCLOUD_TOKEN
curl -sLS https://get.k3sup.dev | sh

trap "hack/dev-down.sh; ./scripts/delete-token.sh $HCLOUD_TOKEN" EXIT
source <(hack/dev-up.sh)

skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}"
tag=$(skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}" --quiet --output="{{ (index .Builds 0).Tag }}")
skaffold deploy --images=hetznercloud/hcloud-cloud-controller-manager=$tag
go test ./tests/e2e -v -timeout 60m
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ deploy/gen/
.coverage.out
.envrc
hcloud-cloud-controller-manager
*.tgz
hack/.*
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test:unit:
variables:
NODE_NAME: "test"
script:
- go test $(go list ./... | grep -v e2etests) -v
- go test $(go list ./... | grep -v e2e) -v
apricote marked this conversation as resolved.
Show resolved Hide resolved
tags:
- hc-bladerunner

Expand Down Expand Up @@ -92,7 +92,7 @@ e2e:
- docker login $CI_REGISTRY --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD
- docker pull $CCM_IMAGE_NAME
script:
- go test $(go list ./... | grep e2etests) -v -timeout 60m
- go test $(go list ./... | grep e2e) -v -timeout 60m
tags:
- hc-bladerunner-build

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ release.
To run unit tests locally, execute

```sh
go test $(go list ./... | grep -v e2etests) -v
go test $(go list ./... | grep -v e2e) -v
```

Check that your go version is up to date, tests might fail if it is not.
Expand Down Expand Up @@ -232,7 +232,7 @@ export KEEP_SERVER_ON_FAILURE=yes # Keep the test server after a test failure.
2. Run the tests

```bash
go test $(go list ./... | grep e2etests) -v -timeout 60m
go test $(go list ./... | grep e2e) -v -timeout 60m
```

The tests will now run and cleanup themselves afterwards. Sometimes it might happen that you need to clean up the
Expand Down
4 changes: 0 additions & 4 deletions e2etests/.gitignore

This file was deleted.

Loading