forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (67 loc) · 2.58 KB
/
check_dependencies.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Check Python Dependencies
on:
pull_request:
defaults:
run:
shell: bash # strict bash
jobs:
check_dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Create Virtual Environment
run: python -m venv .venv
- name: Install Dependencies
run: |
source .venv/bin/activate # Activate the virtual environment
pip install --upgrade pip
pip install -r requirements.txt
- name: List Installed Packages
run: |
source .venv/bin/activate # Activate the virtual environment
pip list --format=columns # List installed packages in columns format
- name: Find Source Repos for Dependencies
id: find_source_repos
run: |
source .venv/bin/activate # Activate the virtual environment
python - << EOF
import subprocess
import re
# Define the first-party and second-party organizations
FIRST_PARTY_ORGS = ["openedx"]
SECOND_PARTY_ORGS = [
"edx", "edx-unsupported", "edx-solutions",
"mitodl",
"overhangio",
"open-craft", "eduNEXT", "raccoongang",
]
# Get the output of 'pip list' command
pip_list_output = subprocess.run(['pip', 'list'], capture_output=True, text=True).stdout
# Find source repositories for each installed package
first_party_repos = []
second_party_repos = []
for line in pip_list_output.split('\n'):
match = re.match(r'([\w-]+) \(([\d.]+)\)', line)
if match:
package_name = match.group(1)
# Assume the source repository URL can be extracted from the package name (modify this as per your project's conventions)
# Here, we just append 'https://github.com/{package_name}' for demonstration purposes
repo_url = f'https://github.com/{package_name}'
if any(org in repo_url for org in FIRST_PARTY_ORGS):
first_party_repos.append(repo_url)
elif any(org in repo_url for org in SECOND_PARTY_ORGS):
second_party_repos.append(repo_url)
print("::set-output name=first_party_repos::{}".format(','.join(first_party_repos)))
print("::set-output name=second_party_repos::{}".format(','.join(second_party_repos)))
EOF
- name: Display Source Repos
run: |
echo "First Party Repositories:"
echo "${{ steps.find_source_repos.outputs.first_party_repos }}"
echo "Second Party Repositories:"
echo "${{ steps.find_source_repos.outputs.second_party_repos }}"