Skip to content

Commit

Permalink
Move from drone to Github Actions for 2.9 (#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitulshah-suse authored Jul 3, 2024
1 parent fbead82 commit 6430a03
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 1,440 deletions.
1,395 changes: 0 additions & 1,395 deletions .drone.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/runs-on.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: .github-private
78 changes: 78 additions & 0 deletions .github/workflows/provisioning-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Provisioning tests

on:
push:
branches:
- 'dev-v*'
- 'release-v*'
pull_request:
branches:
- 'dev-v*'
- 'release-v*'

jobs:
provisioning-test:
permissions:
contents: read
runs-on: runs-on,runner=4cpu-linux-x64,image=legacy-cgroups-for-x64,run-id=${{ github.run_id }}
container:
image: rancher/dapper:v0.6.0
options: --privileged
timeout-minutes: 90
strategy:
matrix:
dist: [rke2, k3s]
k8s-minor: [27, 28, 29, 30]
fail-fast: false
steps:
- name: Force Install GIT latest
run: |
apk add git --update-cache
git --version
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Provisioning test
run: |
dapper provisioning-tests
env:
V2PROV_TEST_DIST: ${{ matrix.dist }}
V2PROV_TEST_RUN_REGEX: "^Test_Provisioning_.*$"
KDM_TEST_K8S_MINOR: ${{ matrix.k8s-minor }}
PREV_COMMIT_PR_SHA: ${{ github.event.pull_request.base.sha }}
PREV_COMMIT_PUSH_SHA: ${{ github.event.before }}

provisioning-operations-test:
permissions:
contents: read
runs-on: runs-on,runner=4cpu-linux-x64,image=legacy-cgroups-for-x64,run-id=${{ github.run_id }}
container:
image: rancher/dapper:v0.6.0
options: --privileged
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
dist: [rke2, k3s]
k8s-minor: [27, 28, 29, 30]
steps:
- name: Force Install GIT latest
run: |
apk add git --update-cache
git --version
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Provisioning Operations tests
run: |
dapper provisioning-tests
env:
V2PROV_TEST_DIST: ${{ matrix.dist }}
V2PROV_TEST_RUN_REGEX: "^Test_Operation_SetA_.*$"
KDM_TEST_K8S_MINOR: ${{ matrix.k8s-minor }}
PREV_COMMIT_PR_SHA: ${{ github.event.pull_request.base.sha }}
PREV_COMMIT_PUSH_SHA: ${{ github.event.before }}
10 changes: 5 additions & 5 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
container:
image: rancher/dapper:v0.6.0
steps:
- name: Force Install GIT latest
run: |
apk add git --update-cache
git --version
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout code
uses: actions/checkout@v4
- name: Retrieve Registy secrets from vault
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/registry-endpoint/credentials token | REGISTRY_ENDPOINT ;
- name: Validate
run: dapper ci

Expand Down
7 changes: 4 additions & 3 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ RUN if [[ "${ARCH}" == "amd64" ]]; then \
ENV YQ_VERSION v4.41.1
RUN wget -q https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH}.tar.gz -O - | tar xz && mv yq_linux_${ARCH} /usr/bin/yq

ENV DAPPER_ENV REPO TAG CI DRONE_BUILD_NUMBER DRONE_BUILD_EVENT DRONE_TAG DRONE_COMMIT_BEFORE \
ENV DAPPER_ENV REPO TAG CI \
PREV_COMMIT_PR_SHA PREV_COMMIT_PUSH_SHA GITHUB_EVENT_NAME GITHUB_RUN_NUMBER GITHUB_REF_TYPE GITHUB_REF_NAME \
REGISTRY_ENDPOINT REGISTRY_USERNAME REGISTRY_PASSWORD \
V2PROV_TEST_DIST V2PROV_TEST_RUN_REGEX KDM_TEST_K8S_MINOR DEBUG
ENV DAPPER_SOURCE /go/src/github.com/rancher/kontainer-driver-metadata
ENV DAPPER_DOCKER_SOCKET true
ARG CI
ARG DRONE_BUILD_NUMBER
ENV DAPPER_RUN_ARGS "--privileged --label CI=${CI} --label DRONE_BUILD_NUMBER=${DRONE_BUILD_NUMBER}"
ARG GITHUB_RUN_NUMBER
ENV DAPPER_RUN_ARGS "--privileged --label CI=${CI} --label DRONE_BUILD_NUMBER=${GITHUB_RUN_NUMBER}"
ENV HOME ${DAPPER_SOURCE}
ENV GOPATH /go
VOLUME /var/lib/rancher
Expand Down
25 changes: 0 additions & 25 deletions scripts/dispatch

This file was deleted.

17 changes: 15 additions & 2 deletions scripts/provisioning-tests
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ if [ -z "${CHANNELS_FILE}" ]; then
esac
fi

# Set previous commit SHA

env

if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
export PREV_COMMIT_SHA=${PREV_COMMIT_PUSH_SHA}
elif [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
export PREV_COMMIT_SHA=${PREV_COMMIT_PR_SHA}
fi

# To be removed/changed once drone setup is removed from rancher/rancher repo.
export DRONE_BUILD_NUMBER=${GITHUB_RUN_NUMBER}

if ! ./scripts/test-run-required.sh; then
exit
fi
Expand Down Expand Up @@ -64,7 +77,7 @@ if [ -z "${SOME_K8S_VERSION}" ]; then
# Get git diff in relevant channel file, find all added versions matching k8s minor, and get the last one
# There should never be a version of a given distro with multiple patches on the same minor added at the same time
# This command should be in sync with the one in test-run-required.sh
SOME_K8S_VERSION=$(git --no-pager diff --no-color -G "^ - version:" $DRONE_COMMIT_BEFORE -- "$CHANNELS_FILE" | grep -P "(^\+\s+- version: v1.$KDM_TEST_K8S_MINOR)" | sed 's/\(^\+\s\+- version: \)//' | tail -n 1)
SOME_K8S_VERSION=$(git --no-pager diff --no-color -G "^ - version:" $PREV_COMMIT_SHA -- "$CHANNELS_FILE" | grep -P "(^\+\s+- version: v1.$KDM_TEST_K8S_MINOR)" | sed 's/\(^\+\s\+- version: \)//' | tail -n 1)
else
# Only possible when not running in CI and env var is not provided, in this case just use latest from data.json
SOME_K8S_VERSION=$(jq -r ".$V2PROV_TEST_DIST.releases[-1].version" <"$METADATA_DIR/data.json")
Expand All @@ -80,7 +93,7 @@ cd "$RANCHER_DIR"
# Uncomment to get provisioning tests to write commands being run to stdout
#sed -i '2s/set -e/set -ex/' ./scripts/provisioning-tests

# Uncomment to get startup logs. Don't leave them on because it slows drone down too much
# Uncomment to get startup logs. Don't leave them on because it slows github actions down too much
#sed -i '110s/#//' ./scripts/provisioning-tests
#sed -i '111s/#//' ./scripts/provisioning-tests
#sed -i '141s/#//' ./scripts/provisioning-tests
Expand Down
12 changes: 6 additions & 6 deletions scripts/test-run-required.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -ex

echo "Checking if rancher integration testing is required"
echo "Environment variable DRONE_BUILD_EVENT is ${DRONE_BUILD_EVENT}"
echo "Environment variable GITHUB_EVENT_NAME is ${GITHUB_EVENT_NAME}"

if [ -z "$CI" ]; then
echo "Not running in CI, rancher integration testing is required"
Expand All @@ -14,15 +14,15 @@ if [ -z "$KDM_TEST_K8S_MINOR" ]; then
exit 1
fi

if [ -z "$DRONE_COMMIT_BEFORE" ]; then
echo "Error: DRONE_COMMIT_BEFORE not defined. This should not be happening in CI"
if [ -z "$PREV_COMMIT_SHA" ]; then
echo "Error: PREV_COMMIT_SHA not defined. This should not be happening in CI"
exit 1
fi

# Only run check if Drone build event is 'push' or 'pull_request'
if [ "${DRONE_BUILD_EVENT}" = "push" ] || [ "${DRONE_BUILD_EVENT}" = "pull_request" ]; then
# Only run check if Github build event is 'push' or 'pull_request'
if [ "${GITHUB_EVENT_NAME}" = "push" ] || [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
# Check if the channels file contains changes to versions from the minor version
if [ "$(git --no-pager diff --no-color -G "^ - version:" $DRONE_COMMIT_BEFORE -- "$CHANNELS_FILE" | grep -c -P "(^\+\s+- version: v1.$KDM_TEST_K8S_MINOR)")" -ne 0 ]; then
if [ "$(git --no-pager diff --no-color -G "^ - version:" $PREV_COMMIT_SHA -- "$CHANNELS_FILE" | grep -c -P "(^\+\s+- version: v1.$KDM_TEST_K8S_MINOR)")" -ne 0 ]; then
exit 0
fi
fi
Expand Down
3 changes: 0 additions & 3 deletions scripts/validate-ci
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ fi

echo Checking if released versions are not changed
go run ./pkg/validation/validation.go release-v2.8

echo Checking the generated regsync.yaml file
regsync check --config ./regsync.yaml
6 changes: 5 additions & 1 deletion scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
fi

COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}

GIT_TAG=$(git tag -l --contains HEAD | head -n 1)
if [[ "$GITHUB_EVENT_NAME" = "push" && "$GITHUB_REF_TYPE" = "tag" ]]; then
GIT_TAG=$GITHUB_REF_NAME
fi

if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
Expand Down

0 comments on commit 6430a03

Please sign in to comment.