-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pgadmin4: init at 6.3 #154764
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
Merged
Merged
pgadmin4: init at 6.3 #154764
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| import ./make-test-python.nix ({ pkgs, lib, ... }: | ||
|
|
||
| let | ||
| pgadmin4SrcDir = "/pgadmin"; | ||
| pgadmin4Dir = "/var/lib/pgadmin"; | ||
| pgadmin4LogDir = "/var/log/pgadmin"; | ||
|
|
||
| python-with-needed-packages = pkgs.python3.withPackages (ps: with ps; [ | ||
| selenium | ||
| testtools | ||
| testscenarios | ||
| flask | ||
| flask-babelex | ||
| flask-babel | ||
| flask-gravatar | ||
| flask_login | ||
| flask_mail | ||
| flask_migrate | ||
| flask_sqlalchemy | ||
| flask_wtf | ||
| flask-compress | ||
| passlib | ||
| pytz | ||
| simplejson | ||
| six | ||
| sqlparse | ||
| wtforms | ||
| flask-paranoid | ||
| psutil | ||
| psycopg2 | ||
| python-dateutil | ||
| sqlalchemy | ||
| itsdangerous | ||
| flask-security-too | ||
| bcrypt | ||
| cryptography | ||
| sshtunnel | ||
| ldap3 | ||
| gssapi | ||
| flask-socketio | ||
| eventlet | ||
| httpagentparser | ||
| user-agents | ||
| wheel | ||
| authlib | ||
| qrcode | ||
| pillow | ||
| pyotp | ||
| ]); | ||
| in | ||
| { | ||
| name = "pgadmin4"; | ||
| meta.maintainers = with lib.maintainers; [ gador ]; | ||
|
|
||
| nodes.machine = { pkgs, ... }: { | ||
| imports = [ ./common/x11.nix ]; | ||
| environment.systemPackages = with pkgs; [ | ||
| pgadmin4 | ||
| postgresql | ||
| python-with-needed-packages | ||
| chromedriver | ||
| chromium | ||
| ]; | ||
| services.postgresql = { | ||
| enable = true; | ||
| authentication = '' | ||
| host all all localhost trust | ||
| ''; | ||
| ensureUsers = [ | ||
| { | ||
| name = "postgres"; | ||
| ensurePermissions = { | ||
| "DATABASE \"postgres\"" = "ALL PRIVILEGES"; | ||
| }; | ||
| } | ||
| ]; | ||
| }; | ||
| }; | ||
|
|
||
| testScript = '' | ||
| machine.wait_for_unit("postgresql") | ||
|
|
||
| # pgadmin4 needs its data and log directories | ||
| machine.succeed( | ||
| "mkdir -p ${pgadmin4Dir} \ | ||
| && mkdir -p ${pgadmin4LogDir} \ | ||
| && mkdir -p ${pgadmin4SrcDir}" | ||
| ) | ||
|
|
||
| machine.succeed( | ||
| "tar xvzf ${pkgs.pgadmin4.src} -C ${pgadmin4SrcDir}" | ||
| ) | ||
|
|
||
| machine.wait_for_file("${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/README.md") | ||
|
|
||
| # set paths and config for tests | ||
| machine.succeed( | ||
| "cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version} \ | ||
| && cp -v web/regression/test_config.json.in web/regression/test_config.json \ | ||
| && sed -i 's|PostgreSQL 9.4|PostgreSQL|' web/regression/test_config.json \ | ||
| && sed -i 's|/opt/PostgreSQL/9.4/bin/|${pkgs.postgresql}/bin|' web/regression/test_config.json \ | ||
| && sed -i 's|\"headless_chrome\": false|\"headless_chrome\": true|' web/regression/test_config.json" | ||
| ) | ||
|
|
||
| # adapt chrome config to run within a sandbox without GUI | ||
| # see https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t#50642913 | ||
| # add chrome binary path. use spaces to satisfy python indention (tabs throw an error) | ||
| # this works for selenium 3 (currently used), but will need to be updated | ||
| # to work with "from selenium.webdriver.chrome.service import Service" in selenium 4 | ||
| machine.succeed( | ||
| "cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version} \ | ||
| && sed -i '\|options.add_argument(\"--disable-infobars\")|a \ \ \ \ \ \ \ \ options.binary_location = \"${pkgs.chromium}/bin/chromium\"' web/regression/runtests.py \ | ||
| && sed -i '\|options.add_argument(\"--no-sandbox\")|a \ \ \ \ \ \ \ \ options.add_argument(\"--headless\")' web/regression/runtests.py \ | ||
| && sed -i '\|options.add_argument(\"--disable-infobars\")|a \ \ \ \ \ \ \ \ options.add_argument(\"--disable-dev-shm-usage\")' web/regression/runtests.py \ | ||
| && sed -i 's|(chrome_options=options)|(executable_path=\"${pkgs.chromedriver}/bin/chromedriver\", chrome_options=options)|' web/regression/runtests.py \ | ||
| && sed -i 's|driver_local.maximize_window()||' web/regression/runtests.py" | ||
| ) | ||
|
|
||
| # don't bother to test LDAP authentification | ||
| with subtest("run browser test"): | ||
| machine.succeed( | ||
| 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \ | ||
| && ${python-with-needed-packages.interpreter} regression/runtests.py --pkg browser --exclude \ | ||
| browser.tests.test_ldap_login.LDAPLoginTestCase,browser.tests.test_ldap_login' | ||
| ) | ||
|
|
||
| # fontconfig is necessary for chromium to run | ||
| # https://github.com/NixOS/nixpkgs/issues/136207 | ||
| with subtest("run feature test"): | ||
| machine.succeed( | ||
| 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \ | ||
| && export FONTCONFIG_FILE=${pkgs.makeFontsConf { fontDirectories = [];}} \ | ||
| && ${python-with-needed-packages.interpreter} regression/runtests.py --pkg feature_tests' | ||
| ) | ||
|
|
||
| with subtest("run resql test"): | ||
| machine.succeed( | ||
| 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \ | ||
| && ${python-with-needed-packages.interpreter} regression/runtests.py --pkg resql' | ||
| ) | ||
| ''; | ||
| }) |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| { stdenv | ||
| , lib | ||
| , python3 | ||
| , fetchurl | ||
| , zlib | ||
| , mkYarnModules | ||
| , sphinx | ||
| , nixosTests | ||
| }: | ||
|
|
||
| let | ||
|
|
||
| pname = "pgadmin"; | ||
| version = "6.3"; | ||
|
|
||
| src = fetchurl { | ||
| url = "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${version}/source/pgadmin4-${version}.tar.gz"; | ||
| sha256 = "0xcg5gx6hf4k15idjkxzsnm5s9829fn4li54ga9qbyfqn3wwpg0h"; | ||
| }; | ||
|
|
||
| yarnDeps = mkYarnModules { | ||
| pname = "${pname}-yarn-deps"; | ||
| inherit version; | ||
| packageJSON = ./package.json; | ||
| yarnLock = ./yarn.lock; | ||
| yarnNix = ./yarn.nix; | ||
| }; | ||
| in | ||
|
|
||
| python3.pkgs.buildPythonApplication rec { | ||
| inherit pname version src; | ||
|
|
||
| # from Dockerfile | ||
| CPPFLAGS = "-DPNG_ARM_NEON_OPT=0"; | ||
|
|
||
| format = "setuptools"; | ||
|
|
||
| postPatch = '' | ||
| # patching Makefile, so it doesn't try to build sphinx documentation here | ||
| # (will do so later) | ||
| substituteInPlace Makefile --replace "LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $(MAKE) -C docs/en_US -f Makefile.sphinx html" "true" | ||
| # fix document which refers a non-existing document and fails | ||
| substituteInPlace docs/en_US/contributions.rst --replace "code_snippets" "" | ||
| patchShebangs . | ||
| # relax dependencies | ||
| substituteInPlace requirements.txt \ | ||
| --replace "Pillow==8.3.*" "Pillow>=8.3.0" \ | ||
| --replace "psycopg2==2.8.*" "psycopg2>=2.8.0" \ | ||
| --replace "cryptography==3.*" "cryptography>=3.0" \ | ||
| --replace "requests==2.25.*" "requests>=2.25.0" | ||
| # don't use Server Mode (can be overridden later) | ||
| substituteInPlace pkg/pip/setup_pip.py \ | ||
| --replace "req = req.replace('psycopg2', 'psycopg2-binary')" "req = req" \ | ||
| --replace "builtins.SERVER_MODE = None" "builtins.SERVER_MODE = False" | ||
| ''; | ||
|
|
||
| preBuild = '' | ||
| # Adapted from pkg/pip/build.sh | ||
| echo Creating required directories... | ||
| mkdir -p pip-build/pgadmin4/docs | ||
|
|
||
| # build the documentation | ||
| cd docs/en_US | ||
| ${sphinx}/bin/sphinx-build -W -b html -d _build/doctrees . _build/html | ||
|
|
||
| # Build the clean tree | ||
| cd ../../web | ||
| cp -r * ../pip-build/pgadmin4 | ||
| cd ../docs | ||
| cp -r * ../pip-build/pgadmin4/docs | ||
| for DIR in `ls -d ??_??/` | ||
| do | ||
| if [ -d ''${DIR}_build/html ]; then | ||
| mkdir -p ../pip-build/pgadmin4/docs/''${DIR}_build | ||
| cp -Rv ''${DIR}_build/html ../pip-build/pgadmin4/docs/''${DIR}_build | ||
| fi | ||
| done | ||
| cd ../ | ||
|
|
||
| cp -r ${yarnDeps}/* pip-build/pgadmin4 | ||
|
|
||
| echo Creating distro config... | ||
| echo HELP_PATH = \'../../docs/en_US/_build/html/\' > pip-build/pgadmin4/config_distro.py | ||
| echo MINIFY_HTML = False >> pip-build/pgadmin4/config_distro.py | ||
|
|
||
| echo Creating manifest... | ||
| echo recursive-include pgadmin4 \* > pip-build/MANIFEST.in | ||
|
|
||
| echo Building wheel... | ||
| cd pip-build | ||
| # copy non-standard setup.py to local directory | ||
| # so setuptools-build-hook can call it | ||
| cp -v ../pkg/pip/setup_pip.py setup.py | ||
| ''; | ||
|
|
||
| nativeBuildInputs = [ python3 python3.pkgs.cython python3.pkgs.pip ]; | ||
| buildInputs = [ | ||
| zlib | ||
| python3.pkgs.wheel | ||
| ]; | ||
|
|
||
| # tests need an own data, log directory | ||
| # and a working and correctly setup postgres database | ||
| # checks will be run through nixos/tests | ||
| doCheck = false; | ||
|
|
||
| propagatedBuildInputs = with python3.pkgs; [ | ||
| flask | ||
| flask-gravatar | ||
| flask_login | ||
| flask_mail | ||
| flask_migrate | ||
| flask_sqlalchemy | ||
| flask_wtf | ||
| flask-compress | ||
| passlib | ||
| pytz | ||
| simplejson | ||
| six | ||
| speaklater3 | ||
| sqlparse | ||
| wtforms | ||
| flask-paranoid | ||
| psutil | ||
| psycopg2 | ||
| python-dateutil | ||
| sqlalchemy | ||
| itsdangerous | ||
| flask-security-too | ||
| bcrypt | ||
| cryptography | ||
| sshtunnel | ||
| ldap3 | ||
| flask-babelex | ||
| flask-babel | ||
| gssapi | ||
| flask-socketio | ||
| eventlet | ||
| httpagentparser | ||
| user-agents | ||
| wheel | ||
| authlib | ||
| qrcode | ||
| pillow | ||
| pyotp | ||
| ]; | ||
|
|
||
| passthru = { | ||
| tests = { inherit (nixosTests) pgadmin4; }; | ||
| }; | ||
|
|
||
| meta = with lib; { | ||
| description = "Administration and development platform for PostgreSQL"; | ||
| homepage = "https://www.pgadmin.org/"; | ||
| license = licenses.mit; | ||
| maintainers = with maintainers; [ gador ]; | ||
| }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.