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

Enhancements to the CI pipeline (Part 1, Take 2) #2946

Merged
merged 4 commits into from
Jul 27, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash -e

# This script drives the various tasks involved in testing and building the
# various artifacts for the Pbench product. It is intended to be run from the
# root directory of a Git branch checkout.


# Install the linter requirements and add them to the PATH.
export PATH=${HOME}/.local/bin:${PATH}
python3 -m pip install --user -r lint-requirements.txt

# If this script is run in a container and the user in the container doesn't
# match the owner of the Git checkout, then Git issues an error; these config
# settings avoid the problem.
GITTOP=$(git rev-parse --show-toplevel 2>&1 | head -n 1)
if [[ ${GITTOP} =~ "fatal: unsafe repository ('/home/root/pbench'" ]] ; then
git config --global --add safe.directory /home/root/pbench
git config --global --add safe.directory /home/root/pbench/agent/stockpile
dbutenhof marked this conversation as resolved.
Show resolved Hide resolved
GITTOP=$(git rev-parse --show-toplevel)
fi

# Install the Dashboard dependencies, including the linter's dependencies and
# the unit test dependencies.
( cd dashboard && npm install )

# Test for code style and lint
black --check .
flake8 .
( cd dashboard && npx eslint "src/**" --max-warnings 0 )

# Run unit tests
tox # Agent and Server unit tests and legacy tests
( cd dashboard && CI=true npm test ) # Dashboard unit tests

exit 0
5 changes: 5 additions & 0 deletions dashboard/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.css
*.ico
*.jpg
*.less
*.svg
5 changes: 5 additions & 0 deletions dashboard/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@
],
"rules": {
"react/prop-types": 0
},
"settings": {
"react": {
"version": "detect"
}
}
}
10 changes: 9 additions & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"eject": "react-scripts eject",
"server": "node server",
"start": "react-app-rewired start",
"test": "react-app-rewired test"
"test": "react-scripts test"
},
"proxy": "http://localhost:3001",
"eslintConfig": {
Expand All @@ -56,6 +56,14 @@
"react-app/jest"
]
},
"jest": {
"transform": {
"^.+\\.[t|j]sx?$": "babel-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!@patternfly)/"
]
},
"browserslist": {
"production": [
">0.2%",
Expand Down
15 changes: 13 additions & 2 deletions dashboard/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { render, screen } from '@testing-library/react';
import App from './App';
import { Provider } from "react-redux";
import store from "store/store";
import React from 'react';

const AppWrapper = () => {
return (
<Provider store={store}>
<App />
</Provider>
);
};

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
render(<AppWrapper />);
const linkElement = screen.getByText('Explore');
expect(linkElement).toBeInTheDocument();
});
4 changes: 2 additions & 2 deletions jenkins/Pipeline.gy
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pipeline {
// the coverage data collection.
sh 'rm -fv pbench'

echo 'Linting, pytest-based unit tests, and legacy unit tests'
sh 'jenkins/run tox'
// Run the "build" (lint, unit tests, etc.) in a container.
sh 'jenkins/run ./build.sh'
}
}
stage('Agent Python3.6 Check') {
Expand Down
5 changes: 3 additions & 2 deletions jenkins/ci.fedora.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ RUN \
parallel \
time \
`#` \
`# Base command used by CI unit test jobs` \
`# Commands for running unit test jobs` \
`#` \
npm \
tox \
&& \
&& \
`#` \
`# Save space in the container image.` \
`#` \
Expand Down
3 changes: 2 additions & 1 deletion jenkins/run
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ _image=${IMAGE:-${_image_repo}/pbench-${_image_role}-${_image_kind}:${_branch_na

podman run \
--userns=keep-id \
--volume $(pwd):${HOME_DIR}/pbench:z \
--volume ${HOME_DIR} \
--volume ${HOME_DIR}/.config \
--volume $(pwd):${HOME_DIR}/pbench:z \
${GIT_BASE_VOLUME} \
-w ${HOME_DIR}/pbench \
--env HOME=${HOME_DIR} \
Expand Down
3 changes: 0 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ setenv =
SKIP_GENERATE_AUTHORS = 1
SKIP_WRITE_GIT_CHANGELOG = 1
deps =
-r{toxinidir}/lint-requirements.txt
-r{toxinidir}/agent/requirements.txt
-r{toxinidir}/agent/test-requirements.txt
-r{toxinidir}/server/requirements.txt
-r{toxinidir}/server/test-requirements.txt
commands =
black --check .
flake8 .
bash -c "{toxinidir}/exec-unittests {envdir} {posargs}"
whitelist_externals =
bash