Skip to content

Commit 1cf6cfc

Browse files
author
Rahul Kumar Yadav
committed
ci:fixes bugs
1 parent 3c83bfa commit 1cf6cfc

File tree

12 files changed

+54
-107
lines changed

12 files changed

+54
-107
lines changed

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DOCKERIMAGE=DOCKER_FILE_PATH_HERE

Access/background_task_manager.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,3 @@ def revoke_request(user_access_mapping, revoker=None):
327327
return True
328328
return False
329329

330-
@shared_task(
331-
autoretry_for=(Exception,), retry_kwargs={"max_retries": 3, "countdown": 5}
332-
)
333-
def add(x, y):
334-
return x + y

BrowserStackAutomation/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# SECURITY WARNING: don't run with debug turned on in production!
3030
DEBUG = True
3131

32-
ALLOWED_HOSTS = ['0.0.0.0','127.0.0.1']
32+
ALLOWED_HOSTS = []
3333

3434

3535
# Application definition

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Set the base image to use to Ubuntu
66
FROM python:3.11-slim-buster AS base
77

8+
ENV DJANGO_SETTINGS_MODULE=BrowserStackAutomation.settings
89
RUN DEBIAN_FRONTEND=noninteractive \
910
apt-get update -y \
1011
&& apt-get install --no-install-recommends -y \
@@ -48,4 +49,4 @@ RUN python manage.py collectstatic --clear --noinput \
4849

4950
FROM nginx:1.23.3 as nginx
5051
COPY --from=static_resource_builder /srv/code/dev/public /etc/nginx/html/
51-
COPY --from=static_resource_builder /srv/code/dev/public /usr/share/nginx/html/
52+
COPY --from=static_resource_builder /srv/code/dev/public /usr/share/nginx/html/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ all: build test lint
55
## make dev : Build and start docker containers - (web/test/db)
66
.PHONY: dev
77
dev:
8-
@export DJANGO_SETTINGS_MODULE=BrowserStackAutomation.settings && python3 scripts/make_config_and_env_and_readme.py && python3 scripts/clone_access_modules.py && python3 scripts/github_test.py && python3 scripts/merge_requirements.py && python3 scripts/merge_config.py && docker-compose build && docker-compose up -d
8+
@export DJANGO_SETTINGS_MODULE=BrowserStackAutomation.settings && python3 scripts/make_config_and_readme.py && python3 scripts/clone_access_modules.py && python3 scripts/github_test.py && python3 scripts/merge_requirements.py && python3 scripts/merge_config.py && docker-compose build && docker-compose up -d
99

1010
## make build : Build and start docker containers - (web and db)
1111
.PHONY: build
@@ -44,7 +44,7 @@ lint_issues:
4444
.PHONY: lint
4545
lint: lint_issues
4646
@python3 -m pylama --version
47-
@pylama --skip "env/*" -r lint_issues || echo "Linter run returned errors. Check lint_issues file for details." && false
47+
@pylama -r lint_issues || echo "Linter run returned errors. Check lint_issues file for details." && false
4848

4949
schema_validate:
5050
@echo $(shell python3 scripts/clone_access_modules.py && python3 scripts/validator.py)

config.json.sample

Lines changed: 30 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,32 @@
11
{
2-
"googleapi": {
3-
"SOCIAL_AUTH_GOOGLE_OAUTH2_KEY": "",
4-
"SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET": "",
5-
"SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS": ""
6-
},
7-
"database": {
8-
"engine": "sqlite3"
9-
},
10-
"access_modules": {
11-
"git_urls": [
12-
"https://github.com/browserstack/enigma-public-access-modules.git"
13-
],
14-
"aws_access": {
15-
"aws_accounts": [
16-
{
17-
"account": "Dev",
18-
"access_key_id": "id",
19-
"secret_access_key": "key"
20-
}
21-
]
22-
},
23-
"confluence_module": {
24-
"CONFLUENCE_BASE_URL": "https://test.atlassian.net",
25-
"ADMIN_EMAIL": "test@browserstack.com",
26-
"API_TOKEN": "xyz"
27-
},
28-
"gcp_access": {
29-
"domains": [
30-
{
31-
"domain_id": "browserstack.com",
32-
"admin_id": "test@browserstack.com",
33-
"service_account_path": "./gcp.json"
34-
}
35-
]
36-
},
37-
"github_access": {
38-
"GITHUB_TOKEN": "test-token",
39-
"GITHUB_BASE_URL": "https://api.github.com",
40-
"GITHUB_ORG": "browserstack"
41-
}
42-
},
43-
"enigmaGroup": {
44-
"MAIL_APPROVER_GROUPS": [
45-
"devnull@browserstack.com"
46-
]
47-
},
48-
"emails": {
49-
"access-approve": "<access-approve-email>"
50-
},
51-
"background_task_manager": {
52-
"type": "celery",
53-
"config": {
54-
"broker": "redis://localhost:6379/0",
55-
"backend": "redis://localhost:6379/0",
56-
"need_monitoring": true,
57-
"monitoring_apps": "django_celery_results"
58-
}
2+
"googleapi": {
3+
"SOCIAL_AUTH_GOOGLE_OAUTH2_KEY": "",
4+
"SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET": "",
5+
"SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS": ""
6+
},
7+
"database": {
8+
"engine": "sqlite3"
9+
},
10+
"access_modules": {
11+
"git_urls": [
12+
"https://github.com/browserstack/enigma-public-access-modules.git"
13+
]
14+
},
15+
"enigmaGroup": {
16+
"MAIL_APPROVER_GROUPS": [
17+
"devnull@browserstack.com"
18+
]
19+
},
20+
"emails": {
21+
"access-approve": "<access-approve-email>"
22+
},
23+
"background_task_manager": {
24+
"type": "celery",
25+
"config": {
26+
"broker": "redis://redis:6379/0",
27+
"backend": "redis://redis:6379/0",
28+
"need_monitoring": true,
29+
"monitoring_apps": "django_celery_results"
5930
}
60-
}
31+
}
32+
}

constants.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"reason8": "The request raised is incorrect or is not required for the reason supplied. Please re-raise with corrections.",
1111
"reason9": "Please raise this via Group Access. Get in touch with your Lead/Manager to get yourself added to relevant Access Groups."
1212
}
13-
}
13+
}

scripts/clone_access_modules.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,26 @@
2323
and file != ".github"
2424
and file != "secrets"
2525
) or (file == "requirements.txt"):
26-
try:
27-
os.rename(
26+
os.rename(
2827
folder_path + "/" + file, "./Access/access_modules/" + file
2928
)
30-
except:
31-
shutil.rmtree(folder_path)
3229

30+
print("Cloning successful!")
31+
32+
except Exception as e:
33+
print(e)
34+
35+
print("failed cloning " + folder_name + ".")
3336
# remove the cloned repo folder entirely with all its contents which
3437
# includes folders and files using shutil.rmtree()
3538
# shutil.rmtree() sometimes throws an error on windows,
3639
# so we use try and except to ignore the error
37-
try:
38-
print("REMOVED" ,folder_path)
39-
shutil.rmtree(folder_path)
40-
except Exception as e:
41-
print(e)
42-
print("failed to remove " + folder_path + " folder.")
43-
44-
print("Cloning successful!")
45-
40+
try:
41+
shutil.rmtree(folder_path)
4642
except Exception as e:
47-
print(e)
48-
print("failed cloning " + folder_name + ".")
43+
print(e)
44+
print("failed to remove " + folder_path + " folder.")
45+
4946
except Exception as e:
5047
print("Access module cloning failed!")
5148
print(str(e))
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
shutil.copy(sample_file, output_file)
1313

1414

15-
# Set the names of the input and output files
16-
sample_file = '.env.sample'
17-
output_file = '.env'
18-
19-
# Check if the output file exists, and create it if it doesn't
20-
if not os.path.exists(output_file):
21-
open(output_file, 'w').close()
22-
# Copy the sample file to the output file
23-
shutil.copy(sample_file, output_file)
24-
25-
2615
# Set the name of the file to be created
2716
filename = 'README.md'
2817

@@ -47,4 +36,6 @@
4736
f.write('```\n\n')
4837
f.write('## License\n\n')
4938
f.write('This project is licensed under the MIT License - see the LICENSE file for details.\n')
50-
print(f"{filename} created successfully!")
39+
print(f"{filename} created successfully!")
40+
41+

scripts/merge_config.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,8 @@
2323

2424
if file_name == 'config.json.sample':
2525
sample_file = 'config.json.sample'
26-
output_file = 'config.json'
2726
sample_file_path = (os.path.join('/'.join(curr_path_array) , sample_file))
28-
output_file_path = (os.path.join('/'.join(curr_path_array) , output_file))
29-
access_module_paths.append(output_file_path)
30-
31-
if not os.path.exists(output_file_path):
32-
open(output_file_path, 'w').close()
33-
shutil.copy(sample_file_path, output_file_path)
27+
access_module_paths.append(sample_file_path)
3428

3529

3630
access_module_tags = []
@@ -65,4 +59,4 @@
6559
# convert into json
6660
config_dict_json = (json.dumps(config_dict))
6761
with open("config.json", "w") as f:
68-
json.dump(config_dict, f)
62+
json.dump(config_dict, f)

0 commit comments

Comments
 (0)