From c5d0fe2220b49df1c38b1af1e5160382cf60ddde Mon Sep 17 00:00:00 2001 From: mvgijssel <6029816+mvgijssel@users.noreply.github.com> Date: Tue, 29 Aug 2023 22:36:00 +0200 Subject: [PATCH] Setup oauth auth for bunqtoynab (#473) * Setup oauth auth for bunqtoynab --- .devcontainer.json | 9 +++------ .vscode/settings.json | 6 ++++-- BUILD.bazel | 2 ++ WORKSPACE.bzlmod | 10 ++++++++-- bin/post-setup | 1 - requirements.txt | 2 +- rules/rules_task/tools/defs.bzl | 5 +++-- tools/bunq2ynab/BUILD.bazel | 19 +++++++++++++++++++ tools/bunq2ynab/BUILD.repositories.bazel.tpl | 1 + 9 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index 298806c13..1f56bde41 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -24,11 +24,7 @@ "settings": { "python.formatting.provider": "black", "python.formatting.blackPath": "/opt/bin/black", - "terminal.integrated.scrollback": 10000, - "files.associations": { - ".bazelrc": "plaintext" - }, - "editor.formatOnSave": true + "terminal.integrated.scrollback": 10000 } } }, @@ -36,7 +32,8 @@ "containerUser": "devcontainer", "mounts": [ "type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock", - "source=setup-bazel,target=/home/devcontainer/bazel,type=volume" + "source=setup-bazel,target=/home/devcontainer/bazel,type=volume", + "source=${localWorkspaceFolder}/../bunq2ynab,target=/workspaces/bunq2ynab,type=bind,consistency=cached" ], "shutdownAction": "stopContainer", "postAttachCommand": "bin/post-setup", diff --git a/.vscode/settings.json b/.vscode/settings.json index ba3d88f66..fc85df35b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,8 @@ "bazel.buildifierExecutable": "/opt/bin/buildifier", "prettier.resolveGlobalModules": false, "files.associations": { - "WORKSPACE.bzlmod": "starlark" - } + "WORKSPACE.bzlmod": "starlark", + ".bazelrc": "plaintext" + }, + "editor.formatOnSave": true } diff --git a/BUILD.bazel b/BUILD.bazel index bf923772d..46b882cbe 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -79,6 +79,8 @@ compile_pip_requirements( name = "requirements", extra_args = [ "--allow-unsafe", + ], + hidden_args = [ "--verbose", ], requirements_in = "requirements.in", diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index 755ad1e90..97d680d76 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -213,6 +213,12 @@ http_archive( git_repository( name = "bunq2ynab", build_file = "//tools/bunq2ynab:BUILD.repositories.bazel.tpl", - commit = "562d63d7d708f7beb18173d4f5c48050fe207aea", - remote = "https://github.com/wesselt/bunq2ynab.git", + commit = "38e62454e86041b604e21db13eafc1d3376de170", + remote = "https://github.com/mvgijssel/bunq2ynab.git", ) + +# new_local_repository( +# name = "bunq2ynab", +# build_file = "//tools/bunq2ynab:BUILD.repositories.bazel.tpl", +# path = "/workspaces/bunq2ynab", +# ) diff --git a/bin/post-setup b/bin/post-setup index daa8a364e..695c9f7fd 100755 --- a/bin/post-setup +++ b/bin/post-setup @@ -8,7 +8,6 @@ sudo chown devcontainer:devcontainer /home/devcontainer/bazel # Ensure the linters are built for local development bazel run --script_path=/opt/bin/black //tools/black -bazel run --script_path=/opt/bin/python //tools/python bazel run --script_path=/opt/bin/lefthook //tools/lefthook bazel run --script_path=/opt/bin/pnpm @pnpm-setup//:pnpm bazel run --script_path=/opt/bin/prettier //:prettier diff --git a/requirements.txt b/requirements.txt index 76f010f52..c8b80476e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --allow-unsafe --verbose --generate-hashes requirements.in +# pip-compile --allow-unsafe --generate-hashes requirements.in # aiohttp==3.8.4 \ --hash=sha256:03543dcf98a6619254b409be2d22b51f21ec66272be4ebda7b04e6412e4b2e14 \ diff --git a/rules/rules_task/tools/defs.bzl b/rules/rules_task/tools/defs.bzl index 4b7bfa499..672c3e464 100644 --- a/rules/rules_task/tools/defs.bzl +++ b/rules/rules_task/tools/defs.bzl @@ -2,11 +2,12 @@ load("@rules_task//:defs.bzl", "cmd", "task") load("@pip//:requirements.bzl", "requirement") load("@bazel_skylib//rules:diff_test.bzl", "diff_test") -def compile_pip_requirements(name, requirements_in, requirements_txt, extra_args = []): +def compile_pip_requirements(name, requirements_in, requirements_txt, extra_args = [], hidden_args = []): pip_compile_name = name pip_compile_update_name = "{}.update".format(name) pip_compile_compare_name = "{}_compare".format(name) pip_compile_test_name = "{}_test".format(name) + pip_compile_hidden_args = hidden_args pip_compile_shared_args = extra_args + [ "--generate-hashes", @@ -16,7 +17,7 @@ def compile_pip_requirements(name, requirements_in, requirements_txt, extra_args requirements_in, ] - pip_compile_args = pip_compile_shared_args + [ + pip_compile_args = pip_compile_shared_args + pip_compile_hidden_args + [ "--output-file", "$REQUIREMENTS_TXT", requirements_in, diff --git a/tools/bunq2ynab/BUILD.bazel b/tools/bunq2ynab/BUILD.bazel index bf7d29e08..789c603e0 100644 --- a/tools/bunq2ynab/BUILD.bazel +++ b/tools/bunq2ynab/BUILD.bazel @@ -59,3 +59,22 @@ task( ), ], ) + +py_binary( + name = "generate_oauth_token_binary", + srcs = ["@bunq2ynab//:generate_oauth_token.py"], + main = "generate_oauth_token.py", + deps = [ + "@bunq2ynab//:lib", + requirement("requests"), + requirement("pyopenssl"), + ], +) + +task( + name = "generate_oauth_token", + cmds = [ + cmd.executable("generate_oauth_token_binary"), + ], + cwd = "$BUILD_WORKSPACE_DIRECTORY", +) diff --git a/tools/bunq2ynab/BUILD.repositories.bazel.tpl b/tools/bunq2ynab/BUILD.repositories.bazel.tpl index 671fc0abc..5a9af4538 100644 --- a/tools/bunq2ynab/BUILD.repositories.bazel.tpl +++ b/tools/bunq2ynab/BUILD.repositories.bazel.tpl @@ -11,4 +11,5 @@ exports_files([ "list_user.py", "list_budget.py", "bunq2ynab.py", + "generate_oauth_token.py", ])