Skip to content

Commit 542a9d3

Browse files
committed
Refine the installation skips
Signed-off-by: tdruez <[email protected]>
1 parent 022539a commit 542a9d3

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

.github/workflows/multi-runs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ jobs:
3232
which scanpipe || { echo "scanpipe not found in PATH"; exit 1; }
3333
which scancode || { echo "scancode not found in PATH"; exit 1; }
3434
echo "Versions:"
35-
scanpipe --version
36-
scancode --version
35+
scanpipe shell -c "import scancodeio; from scancode_config import __version__ as scancode_version;print(f'ScanCode.io version: {scancodeio.__version__}');print(f'ScanCode-toolkit version: v{scancode_version}')"

action.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,40 @@ runs:
6060
echo "SCANCODEIO_DB_USER=scancodeio" >> $GITHUB_ENV
6161
echo "SCANCODEIO_DB_PASSWORD=scancodeio" >> $GITHUB_ENV
6262
63+
- name: Detect if ScanCode.io is already installed
64+
shell: bash
65+
run: |
66+
if command -v scanpipe &> /dev/null; then
67+
echo "ScanCode.io already installed."
68+
echo "SCANCODEIO_IS_INSTALLED=true" >> $GITHUB_ENV
69+
else
70+
echo "ScanCode.io not found."
71+
echo "SCANCODEIO_IS_INSTALLED=false" >> $GITHUB_ENV
72+
fi
73+
6374
- name: Start and setup the PostgreSQL service
75+
if: env.SCANCODEIO_IS_INSTALLED != 'true'
6476
shell: bash
6577
run: |
6678
sudo systemctl start postgresql.service
67-
sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb ${{ env.SCANCODEIO_DB_USER }} || true
68-
sudo -u postgres psql -c "ALTER USER ${{ env.SCANCODEIO_DB_USER }} WITH ENCRYPTED PASSWORD '${{ env.SCANCODEIO_DB_PASSWORD }}'" || true
69-
sudo -u postgres createdb --owner=scancodeio --encoding=UTF-8 ${{ env.SCANCODEIO_DB_NAME }} || true
79+
sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb ${{ env.SCANCODEIO_DB_USER }}
80+
sudo -u postgres psql -c "ALTER USER ${{ env.SCANCODEIO_DB_USER }} WITH ENCRYPTED PASSWORD '${{ env.SCANCODEIO_DB_PASSWORD }}'"
81+
sudo -u postgres createdb --owner=scancodeio --encoding=UTF-8 ${{ env.SCANCODEIO_DB_NAME }}
7082
7183
- name: Install ScanCode.io (only if not already installed)
84+
if: env.SCANCODEIO_IS_INSTALLED != 'true'
7285
shell: bash
7386
run: |
74-
if ! command -v scanpipe &> /dev/null; then
75-
if [ -z "${{ inputs.scancodeio-repo-branch }}" ]; then
76-
echo "Installing the latest ScanCode.io release from PyPI"
77-
pip install --upgrade scancodeio
78-
else
79-
echo "Installing ScanCode.io from the GitHub branch: ${{ inputs.scancodeio-repo-branch }}"
80-
pip install git+https://github.com/aboutcode-org/scancode.io.git@${{ inputs.scancodeio-repo-branch }}
81-
fi
87+
if [ -z "${{ inputs.scancodeio-repo-branch }}" ]; then
88+
echo "Installing the latest ScanCode.io release from PyPI"
89+
pip install --upgrade scancodeio
8290
else
83-
echo "ScanCode.io already installed, skipping installation."
91+
echo "Installing ScanCode.io from the GitHub branch: ${{ inputs.scancodeio-repo-branch }}"
92+
pip install git+https://github.com/aboutcode-org/scancode.io.git@${{ inputs.scancodeio-repo-branch }}
8493
fi
8594
8695
- name: Run migrations to prepare the database
96+
if: env.SCANCODEIO_IS_INSTALLED != 'true'
8797
shell: bash
8898
run: scanpipe migrate --verbosity 0
8999

0 commit comments

Comments
 (0)