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

Fixes #20374: Test ncf in docker #1325

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
148 changes: 93 additions & 55 deletions Jenkinsfile
@@ -1,20 +1,68 @@
@Library('slack-notification')
import org.gradiant.jenkins.slack.SlackNotifier
@Library('rudder-ci-libs@master') _

pipeline {
agent none
triggers { cron('@daily') }
stages {
stage('qa-test') {
agent { label 'script' }
environment {
PATH = "${env.HOME}/.local/bin:${env.PATH}"
stage('Tests') {
parallel {
stage('typos') {
agent {
dockerfile {
filename 'ci/typos.Dockerfile'
additionalBuildArgs '--build-arg VERSION=1.0'
}
}
steps {
dir('language') {
sh script: 'typos', label: 'check language typos'
}
}
post {
always {
script {
new SlackNotifier().notifyResult("shell-team")
}
}
}
}
stage('python') {
agent {
dockerfile {
filename 'ci/python.Dockerfile'
additionalBuildArgs "--build-arg USER_ID=${env.JENKINS_UID}"
}
}
steps {
sh script: './qa-test --python', label: 'python scripts lint'
sh script: './qa-test --quick', label: 'quick method tests'
}
post {
always {
script {
new SlackNotifier().notifyResult("shell-team")
}
}
}
}
}
}
stage('methods') {
agent {
dockerfile {
filename 'ci/methods.Dockerfile'
// Run tests as root
args "--user 0"
additionalBuildArgs "--build-arg OS=ubuntu:20.04"
}
}
steps {
sh script: './qa-test', label: 'qa-test'
sh script: './qa-test --typos', label: 'check typos'
sh script: './qa-test --quick', label: 'check typos'
catchError {
sh script: 'PATH="/opt/rudder/bin:$PATH" make test', label: 'test methods'
}
// clean leftover files owned by root anyway
sh script: 'git clean -fdx', label: 'cleanup'
}
post {
always {
Expand All @@ -23,57 +71,47 @@ pipeline {
}
}
}

}
stage('ncf-tests pull-request') {
agent { label 'rtf' }
when { changeRequest() }
steps {
script {
deleteDir()
dir('ncf') {
checkout scm
sh script: 'git log -1 --pretty=%B'
}
String[] agent_versions = [
"ci/rudder-6.1-nightly",
"ci/rudder-6.2-nightly",
"ci/rudder-7.0-nightly"
]
String[] systems = [
"debian10"
]
String ncf_path = "${workspace}/ncf"
testNcfLocal(agent_versions, systems, ncf_path)
stage("Compatibility tests") {
// Expensive tests only done daily on branches
when {
allOf {
triggeredBy 'TimerTrigger'
not { changeRequest() }
}
}
}
stage('ncf-tests branch') {
agent { label 'rtf' }
when { not { changeRequest() } }
steps {
script {
deleteDir()
dir('ncf') {
checkout scm
sh script: 'git log -1 --pretty=%B'
matrix {
axes {
axis {
name 'OS'
values 'debian:11'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dockerfile is a ubuntu20 based one, not debian11

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad

}
}
stages {
stage('methods') {
agent {
dockerfile {
filename 'ci/methods.Dockerfile'
// Run tests as root
args "--user 0"
additionalBuildArgs "--build-arg OS=${OS}"
}
}
steps {
catchError {
sh script: 'PATH="/opt/rudder/bin:$PATH" make test', label: 'test methods'
}
// clean leftover files owned by root anyway
sh script: 'git clean -fdx', label: 'cleanup'
}
post {
always {
script {
new SlackNotifier().notifyResult("shell-team")
}
}
}
}
String[] agent_versions = [
"ci/rudder-6.1-nightly",
"ci/rudder-6.2-nightly",
"ci/rudder-7.0-nightly"
]
String[] systems = [
"debian10",
"debian9",
"centos7",
"centos8",
"sles12",
"sles15",
"ubuntu18_04"
]
String ncf_path = "${workspace}/ncf"
testNcfLocal(agent_versions, systems, ncf_path)
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions ci/methods.Dockerfile
@@ -0,0 +1,9 @@
ARG OS=ubuntu:20.04
FROM ${OS}

RUN if type apt-get; then apt-get update && apt-get install -y wget gnupg2 make python3-jinja2 fakeroot acl git; fi
RUN if type yum; then yum install -y wget gnupg2 make python3-jinja2 acl git; fi

# Accept all OSes
ENV UNSUPPORTED=y
RUN wget https://repository.rudder.io/tools/rudder-setup && sh ./rudder-setup setup-agent latest || true
12 changes: 12 additions & 0 deletions ci/python.Dockerfile
@@ -0,0 +1,12 @@
FROM debian:11

ARG USER_ID=1000
COPY ci/user.sh .
RUN ./user.sh $USER_ID

RUN apt-get update && apt-get install -y git wget gnupg2 make python3-pip
RUN pip3 install avocado-framework pylint Jinja2

# Accept all OSes
ENV UNSUPPORTED=y
RUN wget https://repository.rudder.io/tools/rudder-setup && sh ./rudder-setup setup-agent latest || true
4 changes: 4 additions & 0 deletions ci/typos.Dockerfile
@@ -0,0 +1,4 @@
FROM rust
ARG VERSION

RUN cargo install -f typos-cli --version =$VERSION
7 changes: 7 additions & 0 deletions ci/user.sh
@@ -0,0 +1,7 @@
#!/bin/sh

# Jenkins user with correct uid
USER_ID=$1
mkdir /home/jenkins
useradd -r -u $USER_ID -d /home/jenkins jenkins
chown jenkins /home/jenkins
2 changes: 1 addition & 1 deletion qa-test
Expand Up @@ -10,7 +10,7 @@ test_python()
{
export PYTHONPATH="./tests/testlib:${PYTHONPATH}"
[ -x "$(command -v pylint3)" ] && pylintCmd="pylint3" || pylintCmd="pylint"
find . -path ./api -prune -o -name '*.py' -exec echo "Running pylint on {}" \; -exec ${pylintCmd} -E --disable=C,R --init-hook="import sys; sys.path.append('./tools')" --persistent=n {} \;
find . -name '*.py' -exec echo "Running pylint on {}" \; -exec ${pylintCmd} -E --disable=C,R --init-hook="import sys; sys.path.append('./tools')" --persistent=n {} \;
}

test_typos()
Expand Down