Skip to content
Closed
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
25 changes: 25 additions & 0 deletions .github/scripts/configure-mise-python-index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -euo pipefail

: "${ARTIFACTORY_URL:?}" "${ARTIFACTORY_USERNAME:?}" "${ARTIFACTORY_ACCESS_TOKEN:?}" "${GITHUB_ENV:?}"

configure_mise_python_index() {
local authenticated_index registry_url

authenticated_index="${ARTIFACTORY_URL%/}/api/pypi/sonarsource-pypi/simple"
authenticated_index="https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${authenticated_index#https://}"
registry_url="${authenticated_index%/}/{}/"

echo "::add-mask::${authenticated_index}"
echo "::add-mask::${registry_url}"
{
echo "PIP_INDEX_URL=${authenticated_index}"
echo "UV_DEFAULT_INDEX=${authenticated_index}"
echo "MISE_PIPX_REGISTRY_URL=${registry_url}"
} >> "$GITHUB_ENV"
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
configure_mise_python_index
fi
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: ./config-npm
- uses: ./config-pip
- uses: SonarSource/gh-action_pre-commit@2ddc0c7fdabce0adfaaa4075a17690972ed9961a # 1.2.0
- uses: SonarSource/gh-action_pre-commit@27ee4b1872173a0bafea002be3c264f97f5c2c5d
with:
extra-args: >
--from-ref=origin/${{ github.event.pull_request.base.ref }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-build-number.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ jobs:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: ./config-pip
- name: Configure mise Python package indexes
run: bash .github/scripts/configure-mise-python-index.sh
- uses: ./config-npm
- uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-shell-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- uses: ./config-pip
- name: Configure mise Python package indexes
run: bash .github/scripts/configure-mise-python-index.sh
- uses: ./config-npm
- uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-update-release-channel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
[[ "${{ steps.urc.outputs.version-key }}" == "Distribution/test-fixture/stable.version" ]]
[[ "${{ steps.urc.outputs.version-url }}" == "https://binaries.sonarsource.com/Distribution/test-fixture/stable.version" ]]
[[ "${{ steps.urc.outputs.version }}" == "0.0.0-test" ]]
- uses: ./config-pip
- name: Configure mise Python package indexes
run: bash .github/scripts/configure-mise-python-index.sh
- uses: ./config-npm
- uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0
with:
Expand Down
33 changes: 33 additions & 0 deletions spec/configure-mise-python-index_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
eval "$(shellspec - -c) exit 1"

export ARTIFACTORY_URL="https://repox.jfrog.io/artifactory"
export ARTIFACTORY_USERNAME="test-user"
export ARTIFACTORY_ACCESS_TOKEN="test-token"
export GITHUB_ENV=/dev/null

Describe '.github/scripts/configure-mise-python-index.sh'
It 'does not configure the environment when sourced'
When run source .github/scripts/configure-mise-python-index.sh
The status should be success
The lines of output should equal 0
End
End

Include .github/scripts/configure-mise-python-index.sh

Describe 'configure_mise_python_index()'
It 'configures mise, uv, and pip to use the authenticated Repox index'
GITHUB_ENV=$(mktemp)
export GITHUB_ENV
When call configure_mise_python_index
The status should be success
The lines of output should equal 2
The contents of file "$GITHUB_ENV" should include \
"PIP_INDEX_URL=https://test-user:test-token@repox.jfrog.io/artifactory/api/pypi/sonarsource-pypi/simple"
The contents of file "$GITHUB_ENV" should include \
"UV_DEFAULT_INDEX=https://test-user:test-token@repox.jfrog.io/artifactory/api/pypi/sonarsource-pypi/simple"
The contents of file "$GITHUB_ENV" should include \
"MISE_PIPX_REGISTRY_URL=https://test-user:test-token@repox.jfrog.io/artifactory/api/pypi/sonarsource-pypi/simple/{}/"
End
End
Loading