Skip to content
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

Use GITHUB_REPOSITORY variable to install requirements from master in actions triggered by a fork #9038

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/engine_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
python-version: ["3.10"]
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_REPOSITORY: ${{ github.repository }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -23,7 +24,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python install.py devel --version=$GITHUB_HEAD_REF
python install.py devel --version=$GITHUB_HEAD_REF --repository=$GITHUB_REPOSITORY
- name: Calculators and documentation tests
run: |
source ~/openquake/bin/activate
Expand All @@ -38,7 +39,8 @@ jobs:
os: [ubuntu-latest]
python-version: ["3.10"]
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_REPOSITORY: ${{ github.repository }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -47,7 +49,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python install.py devel --version=$GITHUB_HEAD_REF
python install.py devel --version=$GITHUB_HEAD_REF --repository=$GITHUB_REPOSITORY
- name: Hazardlib tests
run: |
source ~/openquake/bin/activate
Expand All @@ -65,6 +67,7 @@ jobs:
python-version: ["3.10"]
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_REPOSITORY: ${{ github.repository }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -73,7 +76,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python install.py devel --version=$GITHUB_HEAD_REF
python install.py devel --version=$GITHUB_HEAD_REF --repository=$GITHUB_REPOSITORY
- name: Server 'PUBLIC' mode tests
run: |
source ~/openquake/bin/activate
Expand All @@ -89,6 +92,7 @@ jobs:
python-version: ["3.10"]
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_REPOSITORY: ${{ github.repository }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -97,7 +101,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python install.py devel --version=$GITHUB_HEAD_REF
python install.py devel --version=$GITHUB_HEAD_REF --repository=$GITHUB_REPOSITORY
- name: Server 'READ_ONLY' mode tests
run: |
source ~/openquake/bin/activate
Expand All @@ -113,6 +117,7 @@ jobs:
python-version: ["3.10"]
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_REPOSITORY: ${{ github.repository }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -121,7 +126,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python install.py devel --version=$GITHUB_HEAD_REF
python install.py devel --version=$GITHUB_HEAD_REF --repository=$GITHUB_REPOSITORY
- name: Server 'AELO' mode tests
run: |
source ~/openquake/bin/activate
Expand Down
14 changes: 10 additions & 4 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ def ensure(pip=None, pyvenv=None):
% sys.executable))


def get_branch(version, inst):
def get_requirements_branch(version, inst, repository):
"""
Convert "version" into a branch name
"""
if repository != 'gem/oq-engine':
return 'master'
if version is None:
if (inst is devel or inst is devel_server):
return 'master'
Expand Down Expand Up @@ -336,7 +338,7 @@ def fix_version(commit, venv):
f.write(''.join(lines))


def install(inst, version):
def install(inst, version, repository):
"""
Install the engine in one of the three possible modes
"""
Expand Down Expand Up @@ -383,7 +385,7 @@ def install(inst, version):
'pip', 'wheel'])

# install the requirements
branch = get_branch(version, inst)
branch = get_requirements_branch(version, inst, repository)
if sys.platform == 'darwin':
mac = '_' + platform.machine(), # x86_64 or arm64
else:
Expand Down Expand Up @@ -534,6 +536,10 @@ def remove(inst):
help="version to install (default stable)")
parser.add_argument("--dbport",
help="DbServer port (default 1907 or 1908)")
parser.add_argument("--repository",
help=("The owner and repository name. For example,"
" 'gem/oq-engine' or 'forkowner/oq-engine'"),
default='gem/oq-engine')
args = parser.parse_args()
if args.inst:
inst = globals()[args.inst]
Expand All @@ -542,6 +548,6 @@ def remove(inst):
if args.remove:
remove(inst)
else:
install(inst, args.version)
install(inst, args.version, args.repository)
else:
sys.exit("Please specify the kind of installation")
Loading