Skip to content

Commit

Permalink
Merge pull request SFDO-Tooling#330 from oddbird/main
Browse files Browse the repository at this point in the history
Merge from OddBird fork.
  • Loading branch information
David Glick committed Dec 9, 2020
2 parents 2384adc + a2aca35 commit ae0f883
Show file tree
Hide file tree
Showing 179 changed files with 7,951 additions and 7,935 deletions.
18 changes: 11 additions & 7 deletions .circleci/config.yml
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
working_directory: ~/metecho
docker:
- image: oddbirds/pyjs:v0.2.0
- image: oddbirds/pyjs:v0.4.0
steps:
- checkout
- restore_cache:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
lint:
working_directory: ~/metecho
docker:
- image: oddbirds/pyjs:v0.2.0
- image: oddbirds/pyjs:v0.4.0
steps:
- checkout
- attach_workspace:
Expand All @@ -58,7 +58,7 @@ jobs:
test-client:
working_directory: ~/metecho
docker:
- image: oddbirds/pyjs:v0.2.0
- image: oddbirds/pyjs:v0.4.0
steps:
- checkout
- attach_workspace:
Expand All @@ -79,7 +79,7 @@ jobs:
test-python:
working_directory: ~/metecho
docker:
- image: oddbirds/pyjs:v0.2.0
- image: oddbirds/pyjs:v0.4.0
environment:
DATABASE_URL: postgres://ubuntu:circle_test@localhost:5432/circle_test
DB_ENCRYPTION_KEY: MMkDMBfYL0Xoz3Xu1ENs3AkdCZdJoks5PNlUBkK7KDc=
Expand All @@ -88,8 +88,12 @@ jobs:
DJANGO_SECRET_KEY: test_secret_key
DJANGO_SETTINGS_MODULE: config.settings.test
SECURE_SSL_REDIRECT: False
SFDX_CLIENT_CALLBACK_URL: circle_test
SFDX_CLIENT_ID: circle_test
SFDX_CLIENT_SECRET: circle_test
SFDX_HUB_KEY: circle_test
- image: circleci/redis:5.0
- image: circleci/postgres:12.3
- image: circleci/postgres:12.5
environment:
POSTGRES_DB: circle_test
POSTGRES_PASSWORD: circle_test
Expand Down Expand Up @@ -121,7 +125,7 @@ jobs:
report-test-coverage:
working_directory: ~/metecho
docker:
- image: oddbirds/pyjs:v0.2.0
- image: oddbirds/pyjs:v0.4.0
environment:
COVERALLS_PARALLEL: true
steps:
Expand All @@ -147,7 +151,7 @@ jobs:
build-docs:
working_directory: ~/metecho
docker:
- image: oddbirds/pyjs:v0.2.0
- image: oddbirds/pyjs:v0.4.0
steps:
- checkout
- attach_workspace:
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Expand Up @@ -26,6 +26,7 @@
"xabikos.javascriptsnippets"
],
"settings": {
"terminal.integrated.shell.linux": null,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
Expand Down
4 changes: 3 additions & 1 deletion .eslintrc.yml
Expand Up @@ -51,10 +51,12 @@ rules:
trailingComma: all

# Import
import/default: 0
import/named: 0
import/no-named-as-default: 0
import/order:
- 1
- newlines-between: always
import/named: 1

# Possible Errors
getter-return: 2
Expand Down
22 changes: 22 additions & 0 deletions .github/dependabot.yml
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: pip
directory: '/'
schedule:
interval: weekly
day: wednesday
time: '05:00'
timezone: America/New_York
open-pull-requests-limit: 99
allow:
- dependency-type: direct
- dependency-type: indirect
- package-ecosystem: npm
directory: '/'
schedule:
interval: weekly
day: wednesday
time: '05:00'
timezone: America/New_York
open-pull-requests-limit: 99
versioning-strategy: increase
21 changes: 11 additions & 10 deletions CONTRIBUTING.rst
Expand Up @@ -43,19 +43,19 @@ Docker-based development
can find these values in the shared Keybase team folder --
``metecho/env``)::

SF_CLIENT_KEY=...
SF_CLIENT_ID=...
SF_CLIENT_SECRET=...
DOCKER_SFDX_HUB_KEY=...
SFDX_CLIENT_ID=...
SFDX_CLIENT_SECRET=...
GITHUB_HOOK_SECRET=...
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
GITHUB_APP_ID=...
GITHUB_APP_KEY=...
DOCKER_GITHUB_APP_KEY=...

Note that none of the values should be quoted, and while ``SF_CLIENT_KEY``
and ``GITHUB_APP_KEY`` are RSA private keys, they must have newlines replaced
with ``\n`` in order to work properly with the Docker ``env_file``
configuration option (see `this issue`_).
Note that none of the values should be quoted, and while
``DOCKER_SFDX_HUB_KEY`` and ``DOCKER_GITHUB_APP_KEY`` are RSA private keys,
they must have newlines replaced with ``\n`` in order to work properly with
the Docker ``env_file`` configuration option (see `this issue`_).

3. Run ``./derrick build`` to build/re-build all the container images.

Expand Down Expand Up @@ -109,8 +109,9 @@ variable in Metecho.
Use the app's "App ID" as ``GITHUB_APP_ID``, "Client ID" as
``GITHUB_CLIENT_ID``, and "Client secret" as ``GITHUB_CLIENT_SECRET``.

Finally, generate a new private key for the app, and set it as the
``GITHUB_APP_KEY`` environment variable (the entire key, not a path to one).
Finally, generate a new private key for the app, replace newlines with ``\n``,
and set it as the ``DOCKER_GITHUB_APP_KEY`` environment variable (the entire
key, not a path to one).

Logging in as a superuser
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
13 changes: 10 additions & 3 deletions Dockerfile
@@ -1,4 +1,4 @@
FROM oddbirds/pyjs:v0.2.0
FROM oddbirds/pyjs:v0.4.0

ARG BUILD_ENV=development

Expand All @@ -12,8 +12,11 @@ RUN chmod +x /start-server.sh

# Python requirements:
COPY ./requirements /requirements
RUN pip install --no-cache-dir -r requirements/prod.txt
RUN if [ "${BUILD_ENV}" = "development" ]; then pip install --no-cache-dir -r requirements/dev.txt; fi
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements/prod.txt
RUN if [ "${BUILD_ENV}" = "development" ] ; then \
pip install --no-cache-dir -r requirements/dev.txt; \
fi

# Install sfdx
RUN mkdir sfdx && wget -qO- https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz | tar xJ -C sfdx --strip-components 1 && ./sfdx/install && rm -rf sfdx
Expand All @@ -35,6 +38,10 @@ RUN DATABASE_URL="" \
DB_ENCRYPTION_KEY="IfFzxkuTnuk-J-TnjisNz0wlBHmAILOnAzoG-NpMQNE=" \
DJANGO_HASHID_SALT="sample hashid salt" \
DJANGO_SECRET_KEY="sample secret key" \
SFDX_CLIENT_SECRET="sample secret" \
SFDX_CLIENT_CALLBACK_URL="sample callback" \
SFDX_CLIENT_ID="sample id" \
SFDX_HUB_KEY="sample key" \
python manage.py collectstatic --noinput

CMD /start-server.sh
8 changes: 4 additions & 4 deletions app.json
Expand Up @@ -51,16 +51,16 @@
"GITHUB_APP_KEY": {
"description": "RSA private key for GitHub App"
},
"SF_CALLBACK_URL": {
"SFDX_CLIENT_CALLBACK_URL": {
"description": "Callback URL for Salesforce Connected App (e.g. \"https://<...>/accounts/salesforce/login/callback/\")"
},
"SF_CLIENT_ID": {
"SFDX_CLIENT_ID": {
"description": "Consumer Key for Salesforce Connected App"
},
"SF_CLIENT_SECRET": {
"SFDX_CLIENT_SECRET": {
"description": "Consumer Secret for Salesforce Connected App"
},
"SF_CLIENT_KEY": {
"SFDX_HUB_KEY": {
"description": "RSA private key matching digital certificate on Salesforce Connected App"
}
},
Expand Down
39 changes: 32 additions & 7 deletions config/settings/base.py
Expand Up @@ -227,7 +227,8 @@ def env(name, default=NoDefaultValue, type_=str):
GITHUB_USER_NAME = env("GITHUB_USER_NAME", default="GitHub user")
GITHUB_APP_ID = env("GITHUB_APP_ID", default=0, type_=int)
# Ugly hack to fix https://github.com/moby/moby/issues/12997
GITHUB_APP_KEY = bytes(env("GITHUB_APP_KEY", default="").replace("\\n", "\n"), "utf-8")
DOCKER_GITHUB_APP_KEY = env("DOCKER_GITHUB_APP_KEY", default="").replace("\\n", "\n")
GITHUB_APP_KEY = bytes(env("GITHUB_APP_KEY", default=DOCKER_GITHUB_APP_KEY), "utf-8")


# Salesforce Devhub settings:
Expand Down Expand Up @@ -343,12 +344,36 @@ def env(name, default=NoDefaultValue, type_=str):
GITHUB_OAUTH_SCOPES.append("repo" if GITHUB_OAUTH_PRIVATE_REPO else "public_repo")

# SF client settings:
SF_CALLBACK_URL = env("SF_CALLBACK_URL", default=None)
SFDX_CLIENT_CALLBACK_URL = env(
"SFDX_CLIENT_CALLBACK_URL", default=env("SF_CALLBACK_URL", default=None)
)
SFDX_CLIENT_ID = env("SFDX_CLIENT_ID", default=env("SF_CLIENT_ID", default=None))
SFDX_CLIENT_SECRET = env(
"SFDX_CLIENT_SECRET", default=env("SF_CLIENT_SECRET", default=None)
)
SFDX_SIGNUP_INSTANCE = env(
"SFDX_SIGNUP_INSTANCE", default=env("SF_SIGNUP_INSTANCE", default=None)
)
# Ugly hack to fix https://github.com/moby/moby/issues/12997
SF_CLIENT_KEY = env("SF_CLIENT_KEY", default="").replace("\\n", "\n")
SF_CLIENT_ID = env("SF_CLIENT_ID", default=None)
SF_CLIENT_SECRET = env("SF_CLIENT_SECRET", default=None)
SF_SIGNUP_INSTANCE = env("SF_SIGNUP_INSTANCE", default=None)
DOCKER_SFDX_HUB_KEY = env("DOCKER_SFDX_HUB_KEY", default="").replace("\\n", "\n")
SFDX_HUB_KEY = env(
"SFDX_HUB_KEY", default=env("SF_CLIENT_KEY", default=DOCKER_SFDX_HUB_KEY)
)

if not SFDX_CLIENT_SECRET:
raise ImproperlyConfigured("Missing environment variable: SFDX_CLIENT_SECRET.")
if not SFDX_CLIENT_CALLBACK_URL:
raise ImproperlyConfigured(
"Missing environment variable: SFDX_CLIENT_CALLBACK_URL."
)
if not SFDX_CLIENT_ID:
raise ImproperlyConfigured("Missing environment variable: SFDX_CLIENT_ID.")
if not SFDX_HUB_KEY:
raise ImproperlyConfigured("Missing environment variable: SFDX_HUB_KEY.")

# CCI expects these env vars to be set to refresh org oauth tokens
environ["SFDX_CLIENT_ID"] = SFDX_CLIENT_ID
environ["SFDX_HUB_KEY"] = SFDX_HUB_KEY

SOCIALACCOUNT_PROVIDERS = {
"github": {
Expand All @@ -357,7 +382,7 @@ def env(name, default=NoDefaultValue, type_=str):
},
"salesforce": {
"SCOPE": ["web", "full", "refresh_token"],
"APP": {"client_id": SF_CLIENT_ID, "secret": SF_CLIENT_SECRET},
"APP": {"client_id": SFDX_CLIENT_ID, "secret": SFDX_CLIENT_SECRET},
},
}
ACCOUNT_EMAIL_REQUIRED = True
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Expand Up @@ -18,6 +18,7 @@ services:
DJANGO_SETTINGS_MODULE: config.settings.local
DATABASE_URL: postgres://metecho:sample_db_password@postgres:5432/metecho
REDIS_URL: redis://redis:6379
REDIS_HOST: redis
volumes:
- .:/app:cached
- /app/node_modules
Expand All @@ -34,7 +35,7 @@ services:

# Runs the database process:
postgres:
image: postgres:12.3
image: postgres:12.5
restart: always
environment:
POSTGRES_USER: metecho
Expand Down
61 changes: 61 additions & 0 deletions docs/api/epics.rst
@@ -0,0 +1,61 @@
=====
Epics
=====

This allows list, retrieve, create, update, and delete of Epics.

Retrieve
--------

.. sourcecode:: http

GET /api/epics/ HTTP/1.1

.. sourcecode:: http

HTTP/1.1 200 OK

{
"count": 150,
"next": "https://.../api/epics/?page=2",
"previous": null,
"results": [
{
"id": "3Lw7OwK",
"name": "Test Epic",
"description": "This is *safely* rendered Markdown.",
"description_rendered": "<p>This is <em>safely</em> rendered Markdown.</p>",
"slug": "test-epic",
"old_slugs": [],
"project": "zVQYrye",
"branch_name": "feature/test-epic",
"branch_url": "https://github.com/SFDO-Tooling/test-project/tree/feature/test-epic",
"branch_diff_url": "https://github.com/SFDO-Tooling/test-project/compare/main...feature/test-epic",
"has_unmerged_commits": true,
"currently_creating_pr": false,
"currently_fetching_org_config_names": false,
"pr_url": "https://github.com/SFDO-Tooling/test-project/pull/1357",
"pr_is_open": true,
"pr_is_merged": false,
"github_users": [
{
"id": "12345",
"login": "username",
"avatar_url": "https://avatars0.githubusercontent.com/u/someId?v=4"
}
],
"status": "In progress",
"available_task_org_config_names": [
{
"key": "dev",
"label": "Dev Org",
"description": "Org set up for package development"
},
{
"key": "qa"
}
]
}
...
]
}
2 changes: 1 addition & 1 deletion docs/api/index.rst
Expand Up @@ -6,7 +6,7 @@ API Reference
:caption: Contents:

user
repositories
projects
epics
tasks
scratch-orgs

0 comments on commit ae0f883

Please sign in to comment.