Skip to content

Commit

Permalink
Merge branch 'main' into multiple-private-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zh committed Dec 11, 2024
2 parents 00b24c8 + dd2b3f2 commit edc1250
Show file tree
Hide file tree
Showing 115 changed files with 3,070 additions and 1,765 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/enforce-PR-labelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: PR Validation

on:
pull_request:
# one limitation here is that there's no trigger to re-run any time we "connect" or "disconnect" an issue
types: [opened, edited, labeled, unlabeled, synchronize]
workflow_dispatch:

jobs:
validate-pr:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Validate PR has labels
id: check_labels
run: |
PR_LABELS=$(jq -r '.pull_request.labels | length' $GITHUB_EVENT_PATH)
if [ "$PR_LABELS" -eq "0" ]; then
echo "No labels found on the pull request."
exit 1
fi
- name: Validate PR is linked to an issue
id: check_linked_issues
run: |
PR_NUMBER=$(jq -r '.pull_request.number' $GITHUB_EVENT_PATH)
REPO_OWNER=$(jq -r '.repository.owner.login' $GITHUB_EVENT_PATH)
REPO_NAME=$(jq -r '.repository.name' $GITHUB_EVENT_PATH)
TIMELINE_JSON=$(curl -s "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/timeline")
# Count the number of times the timeline sees a "connected" event and subract the number of "disconnected" events
# We might also consider using the "cross-referenced" event in the future if actual connecting/disconnecting is too heavy-handed
LINKED_ISSUES=$(echo "$TIMELINE_JSON" | jq '
reduce .[] as $event (
0;
if $event.event == "connected" then
. + 1
elif $event.event == "disconnected" then
. - 1
else
.
end
)')
# If the sum is 0, then no linked issues were found
if [ "$LINKED_ISSUES" -eq "0" ]; then
echo "❌ No linked issues found in the pull request."
exit 1
elif [ "$LINKED_ISSUES" -lt "0" ]; then
echo "Error: More disconnected events than connected events. This shouldn't be possible and likely indicates a big ol' 🪲"
exit 1
else
echo "Linked issues found: $LINKED_ISSUES"
fi
32 changes: 32 additions & 0 deletions .github/workflows/enforce-issue-labelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Issue Validation

on:
issues:
types: [closed]

jobs:
validate-issue:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Validate issue has labels
id: check_labels
run: |
ISSUE_LABELS=$(jq -r '.issue.labels | length' $GITHUB_EVENT_PATH)
if [ "$ISSUE_LABELS" -eq "0" ]; then
echo "No labels found on the issue."
# Re-open the issue
ISSUE_NUMBER=$(jq -r '.issue.number' $GITHUB_EVENT_PATH)
REPO_OWNER=$(jq -r '.repository.owner.login' $GITHUB_EVENT_PATH)
REPO_NAME=$(jq -r '.repository.name' $GITHUB_EVENT_PATH)
curl -L \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$ISSUE_NUMBER \
-d '{"state":"open"}'
exit 1
fi
15 changes: 15 additions & 0 deletions .github/workflows/post-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Toggle webhook to pull latest release onto pelicanplatform.org and update the download offerings there
# Post release this will result in the new release being available and the Major/Minor pointers being moved/created accordingly
name: post-release

on:
release:
types: [published]

jobs:
toggle-webhook:
runs-on: ubuntu-latest
steps:
- name: Toggle Webhook
run: |
curl -X POST https://dl.pelicanplatform.org/api/api/hooks/release-download-toggle
99 changes: 99 additions & 0 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Test Template

on:
workflow_call:
inputs:
tags:
required: true
type: string
coverprofile:
required: true
type: string
binary_name:
required: true
type: string

jobs:
test:
runs-on: ubuntu-latest
container:
image: hub.opensciencegrid.org/pelican_platform/pelican-dev:latest-itb
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Fetch tags
run: |
git config --global --add safe.directory /__w/pelican/pelican
git fetch --force --tags
- name: Cache Next.js
uses: actions/cache@v4
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Test
run: |
make web-build
go test -tags=${{ inputs.tags }} -timeout 15m -coverpkg=./... -coverprofile=${{ inputs.coverprofile }} -covermode=count ./...
- name: Get total code coverage
if: github.event_name == 'pull_request'
id: cc
run: |
set -x
cc_total=`go tool cover -func=${{ inputs.coverprofile }} | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "cc_total=$cc_total" >> $GITHUB_OUTPUT
- name: Restore base test coverage
id: base-coverage
if: github.event.pull_request.base.sha != ''
uses: actions/cache@v4
with:
path: |
unit-base.txt
key: ${{ runner.os }}-unit-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
- name: Run test for base code
if: steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git fetch origin main ${{ github.event.pull_request.base.sha }}
HEAD=$(git rev-parse HEAD)
git reset --hard ${{ github.event.pull_request.base.sha }}
make web-build
go generate ./...
go test -tags=${{ inputs.tags }} -timeout 15m -coverpkg=./... -coverprofile=base_coverage.out -covermode=count ./...
go tool cover -func=base_coverage.out > unit-base.txt
git reset --hard $HEAD
- name: Get base code coverage value
if: github.event_name == 'pull_request'
id: cc_b
run: |
set -x
cc_base_total=`grep total ./unit-base.txt | grep -Eo '[0-9]+\.[0-9]+'`
echo "cc_base_total=$cc_base_total" >> $GITHUB_OUTPUT
- name: Add coverage information to action summary
if: github.event_name == 'pull_request'
run: echo 'Code coverage ' ${{steps.cc.outputs.cc_total}}'% Prev ' ${{steps.cc_b.outputs.cc_base_total}}'%' >> $GITHUB_STEP_SUMMARY
- name: Run GoReleaser for Ubuntu
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: build --single-target --clean --snapshot
- name: Copy files (Ubuntu)
run: |
cp dist/${{ inputs.binary_name }}_linux_amd64_v1/${{ inputs.binary_name }} ./pelican
- name: Run Integration Tests
run: ./github_scripts/citests.sh
- name: Run End-to-End Test for Object get/put
run: ./github_scripts/get_put_test.sh
- name: Run End-to-End Test for Director stat
run: ./github_scripts/stat_test.sh
- name: Run End-to-End Test for --version flag
run: ./github_scripts/version_test.sh
106 changes: 13 additions & 93 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
# Do fetch depth 0 here because otherwise goreleaser might not work properly:
# https://goreleaser.com/ci/actions/?h=tag#workflow
# Do fetch depth 0 here because otherwise goreleaser might not work properly:
# https://goreleaser.com/ci/actions/?h=tag#workflow
fetch-depth: 0
- uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -55,94 +55,14 @@ jobs:
version: latest
args: build --single-target --clean --snapshot
test-ubuntu:
runs-on: ubuntu-latest
container:
image: hub.opensciencegrid.org/pelican_platform/pelican-dev:latest-itb
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# See above for why fetch depth is 0 here
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
# Fetch the tags is essential so that goreleaser can build the correct version. Workaround found here:
# https://github.com/actions/checkout/issues/290
- name: Fetch tags
run: |
git config --global --add safe.directory /__w/pelican/pelican
git fetch --force --tags
- name: Cache Next.js
uses: actions/cache@v4
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Test
run: |
make web-build
go test -timeout 15m -coverpkg=./... -coverprofile=coverage.out -covermode=count ./...
- name: Get total code coverage
if: github.event_name == 'pull_request'
id: cc
run: |
set -x
cc_total=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "cc_total=$cc_total" >> $GITHUB_OUTPUT
- name: Restore base test coverage
id: base-coverage
if: github.event.pull_request.base.sha != ''
uses: actions/cache@v4
with:
path: |
unit-base.txt
# Use base sha for PR or new commit hash for master/main push in test result key.
key: ${{ runner.os }}-unit-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
- name: Run test for base code
if: steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git fetch origin main ${{ github.event.pull_request.base.sha }}
HEAD=$(git rev-parse HEAD)
git reset --hard ${{ github.event.pull_request.base.sha }}
make web-build
go generate ./...
go test -timeout 15m -coverpkg=./... -coverprofile=base_coverage.out -covermode=count ./...
go tool cover -func=base_coverage.out > unit-base.txt
git reset --hard $HEAD
- name: Get base code coverage value
if: github.event_name == 'pull_request'
id: cc_b
run: |
set -x
cc_base_total=`grep total ./unit-base.txt | grep -Eo '[0-9]+\.[0-9]+'`
echo "cc_base_total=$cc_base_total" >> $GITHUB_OUTPUT
- name: Add coverage information to action summary
if: github.event_name == 'pull_request'
run: echo 'Code coverage ' ${{steps.cc.outputs.cc_total}}'% Prev ' ${{steps.cc_b.outputs.cc_base_total}}'%' >> $GITHUB_STEP_SUMMARY
- name: Run GoReleaser for Ubuntu
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: --clean --snapshot
- name: Copy files (Ubuntu)
run: |
cp dist/pelican_linux_amd64_v1/pelican ./
- name: Run Integration Tests
run: ./github_scripts/citests.sh
- name: Run End-to-End Test for Object get/put
run: ./github_scripts/get_put_test.sh
- name: Run End-to-End Test for Director stat
run: ./github_scripts/stat_test.sh
- name: Run End-to-End Test of x509 access
run: ./github_scripts/x509_test.sh
- name: Run End-to-End Test for --version flag
run: ./github_scripts/version_test.sh
uses: ./.github/workflows/test-template.yml
with:
tags: ""
coverprofile: "coverage.out"
binary_name: "pelican"
test-ubuntu-server:
uses: ./.github/workflows/test-template.yml
with:
tags: "lotman"
coverprofile: "coverage-server.out"
binary_name: "pelican-server"
32 changes: 31 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,30 @@ builds:
goarch: ppc64le
- goos: darwin
goarch: ppc64le

# Set things up to build a second server binary that enables Lotman. Eventually
# we'll also use this to filter which moduels are built into the binary.
- env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- "amd64"
- "arm64"
id: "pelican-server"
dir: ./cmd
binary: pelican-server
tags:
- forceposix
- lotman
ldflags:
- -s -w -X github.com/pelicanplatform/pelican/config.commit={{.Commit}} -X github.com/pelicanplatform/pelican/config.date={{.Date}} -X github.com/pelicanplatform/pelican/config.builtBy=goreleaser -X github.com/pelicanplatform/pelican/config.version={{.Version}}
# Goreleaser complains if there's a different number of binaries built for different architectures
# in the same archive. Instead of plopping pelican-server in the same archive as pelican, split the
# builds into separate archives.
archives:
- id: pelican
builds:
- pelican
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
Expand All @@ -62,6 +83,15 @@ archives:
- goos: windows
format: zip
wrap_in_directory: '{{ .ProjectName }}-{{ trimsuffix .Version "-next" }}'
- id: pelican-server
builds:
- pelican-server
name_template: >-
{{ .ProjectName }}-server_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else }}{{ .Arch }}{{ end }}
wrap_in_directory: '{{ .ProjectName }}-server-{{ trimsuffix .Version "-next" }}'
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
Loading

0 comments on commit edc1250

Please sign in to comment.