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

ci(nss): handle system-, cached-, and to-be-build-NSS #2142

Merged
merged 2 commits into from
Oct 1, 2024
Merged
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
33 changes: 17 additions & 16 deletions .github/actions/nss/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ runs:
run: |
if ! command -v pkg-config &> /dev/null; then
echo "pkg-config: not found"
echo "BUILD_NSS=1" >> "$GITHUB_ENV"
echo "USE_SYSTEM_NSS=0" >> "$GITHUB_ENV"
exit 0
fi
if ! pkg-config --exists nss; then
echo "pkg-config: NSS not found"
echo "BUILD_NSS=1" >> "$GITHUB_ENV"
echo "USE_SYSTEM_NSS=0" >> "$GITHUB_ENV"
exit 0
fi
NSS_VERSION="$(pkg-config --modversion nss)"
if [ "$?" -ne 0 ]; then
echo "pkg-config: failed to determine NSS version"
echo "BUILD_NSS=1" >> "$GITHUB_ENV"
echo "USE_SYSTEM_NSS=0" >> "$GITHUB_ENV"
exit 0
fi
NSS_MAJOR=$(echo "$NSS_VERSION" | cut -d. -f1)
Expand All @@ -53,11 +53,11 @@ runs:
REQ_NSS_MINOR=$(echo "${{ inputs.minimum-version}}" | cut -d. -f2)
if [[ "$NSS_MAJOR" -lt "$REQ_NSS_MAJOR" || "$NSS_MAJOR" -eq "$REQ_NSS_MAJOR" && "$NSS_MINOR" -lt "$REQ_NSS_MINOR" ]]; then
echo "System NSS is too old: $NSS_VERSION"
echo "BUILD_NSS=1" >> "$GITHUB_ENV"
echo "USE_SYSTEM_NSS=0" >> "$GITHUB_ENV"
exit 0
fi
echo "System NSS is suitable: $NSS_VERSION"
echo "BUILD_NSS=0" >> "$GITHUB_ENV"
echo "USE_SYSTEM_NSS=1" >> "$GITHUB_ENV"

- name: Use sccache
# Apparently the action can't be installed twice in the same workflow, so check if
Expand All @@ -66,11 +66,11 @@ runs:
#
# Also, only enable sscache on our self-hosted runner, because the GitHub cache limit
# is too small for this to be effective there.
if: env.SCCACHE_ENABLED != '1' && env.BUILD_NSS == '1' && runner.environment != 'github-hosted'
if: env.SCCACHE_ENABLED != '1' && env.USE_SYSTEM_NSS == '0' && runner.environment != 'github-hosted'
uses: mozilla-actions/sccache-action@2e7f9ec7921547d4b46598398ca573513895d0bd # v0.0.4

- name: Enable sscache
if: env.BUILD_NSS == '1' && runner.environment != 'github-hosted'
if: env.USE_SYSTEM_NSS == '0' && runner.environment != 'github-hosted'
shell: bash
run: |
echo "SCCACHE_ENABLED=1" >> "$GITHUB_ENV"
Expand All @@ -86,21 +86,21 @@ runs:
fi

- name: Checkout NSS
if: env.BUILD_NSS == '1'
if: env.USE_SYSTEM == '0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USE_SYSTEM_NSS !

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uff, good catch. Thank you @martinthomson! Will be fixed in #2145.

uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: nss-dev/nss
path: nss

- name: Checkout NSPR
if: env.BUILD_NSS == '1'
if: env.USE_SYSTEM_NSS == '0'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: nss-dev/nspr
path: nspr

- name: Get head revisions
if: env.BUILD_NSS == '1'
if: env.USE_SYSTEM_NSS == '0'
shell: bash
run: |
NSS_HEAD=$(git -C nss rev-parse HEAD)
Expand All @@ -110,21 +110,22 @@ runs:

- name: Cache NSS
id: cache
if: env.BUILD_NSS == '1' && runner.environment == 'github-hosted'
if: env.USE_SYSTEM_NSS == '0' && runner.environment == 'github-hosted'
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: dist
key: nss-${{ runner.os }}-${{ inputs.type }}-${{ env.NSS_HEAD }}-${{ env.NSPR_HEAD }}

- name: Check if build is needed
if: env.BUILD_NSS == '1' && runner.environment == 'github-hosted'
if: env.USE_SYSTEM_NSS == '0'
shell: bash
run: |
if [ "${{ steps.cache.outputs.cache-hit }}" == "true" ]; then
if [ "${{ runner.environment }}" != "github-hosted" ] || [ "${{ steps.cache.outputs.cache-hit }}" == "false" ]; then
echo "Building NSS from source"
echo "BUILD_NSS=1" >> "$GITHUB_ENV"
else
echo "Using cached prebuilt NSS"
echo "BUILD_NSS=0" >> "$GITHUB_ENV"
else
echo "Building NSS from source"
fi

- name: Install build dependencies (Linux)
Expand Down Expand Up @@ -176,6 +177,7 @@ runs:

- name: Set up environment
shell: bash
if: env.USE_SYSTEM_NSS == '0'
run: |
NSS_TARGET="${{ inputs.type }}"
echo "NSS_TARGET=$NSS_TARGET" >> "$GITHUB_ENV"
Expand All @@ -187,7 +189,6 @@ runs:
echo "NSS_PREBUILT=1" >> "$GITHUB_ENV"
env:
NSS_DIR: ${{ github.workspace }}/nss
NSPR_DIR: ${{ github.workspace }}/nspr
larseggert marked this conversation as resolved.
Show resolved Hide resolved

- name: Build
shell: bash
Expand Down
Loading