Skip to content

Commit

Permalink
Move from drone to Github Actions for 2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
mitulshah-suse committed Jun 17, 2024
1 parent a8fba30 commit 4ad671b
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 1,431 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: 60
strategy:
matrix:
dist: [rke2, k3s]
k8s-minor: [25, 26, 27, 28, 29]
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: 60
strategy:
fail-fast: false
matrix:
dist: [rke2, k3s]
k8s-minor: [25, 26, 27, 28, 29]
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 }}
5 changes: 5 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ 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
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ 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 \
PREV_COMMIT_PR_SHA PREV_COMMIT_PUSH_SHA GITHUB_EVENT_NAME GITHUB_RUN_NUMBER \
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.

24 changes: 21 additions & 3 deletions scripts/provisioning-tests
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ 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
export DRONE_BUILD_NUMBER=${GITHUB_RUN_NUMBER}

if ! ./scripts/test-run-required.sh; then
exit
fi
Expand Down Expand Up @@ -64,12 +79,15 @@ 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")
fi
export SOME_K8S_VERSION
#TO BE REMOVED
#SOME_K8S_VERSION=`grep "v1.$KDM_TEST_K8S_MINOR" $CHANNELS_FILE | grep version | tail -n -1 | cut -d: -f2 | tr -d v | tr -d ' '`
#echo "Setting SOME_K8S_VERSION to $SOME_K8S_VERSION"
export SOME_K8S_VERSION=1.27.10+rke2r1
fi

# Copy rancher provisioning tests, and enter directory they exist
Expand All @@ -86,6 +104,6 @@ cd "$RANCHER_DIR"
#sed -i '141s/#//' ./scripts/provisioning-tests

# Remove superfluous check for UI only bumps in this context
sed -i -e '3,5d' ./scripts/provisioning-tests
#sed -i -e '3,5d' ./scripts/provisioning-tests

./scripts/provisioning-tests
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 DRONE_BUILD_EVENT is ${GITHUB_EVENT_NAME}"

if [ -z "$CI" ]; then
echo "Not running in CI, rancher integration testing is required"
Expand All @@ -14,17 +14,17 @@ 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
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
fi

echo "Skipping CI, no changes detected for relevant minor version"
Expand Down

0 comments on commit 4ad671b

Please sign in to comment.