Skip to content
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
562 changes: 324 additions & 238 deletions .github/workflows/build-and-test.yml

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion .github/workflows/check-go-generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set Go version
# Determine the string to use in setup-go's "go-version" input.
id: go-version
run: |
version=$(grep -E '^go[[:space:]]*[0-9]+\.[0-9]+' go.mod | grep -oE '[0-9]+\.[0-9]+')
echo "version=${version}.x" >> $GITHUB_OUTPUT

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
go-version: "${{ steps.go-version.outputs.version }}"
check-latest: true
cache: false

Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/pre-commit-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set Go version
# Determine the string to use in setup-go's "go-version" input.
id: go-version
run: |
version=$(grep -E '^go[[:space:]]*[0-9]+\.[0-9]+' go.mod | grep -oE '[0-9]+\.[0-9]+')
echo "version=${version}.x" >> $GITHUB_OUTPUT

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
go-version: "${{ steps.go-version.outputs.version }}"
check-latest: true
cache: false

Expand Down Expand Up @@ -63,6 +70,7 @@ jobs:
node-version-file: "web_ui/frontend/package.json"
cache: "npm"
cache-dependency-path: "web_ui/frontend/package-lock.json"
check-latest: true

- name: Run Prettier
run: |
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ jobs:
node-version-file: "web_ui/frontend/package.json"
cache: "npm"
cache-dependency-path: "web_ui/frontend/package-lock.json"
check-latest: true

- name: Set Go version
# Determine the string to use in setup-go's "go-version" input.
id: go-version
run: |
version=$(grep -E '^go[[:space:]]*[0-9]+\.[0-9]+' go.mod | grep -oE '[0-9]+\.[0-9]+')
echo "version=${version}.x" >> $GITHUB_OUTPUT

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
go-version: "${{ steps.go-version.outputs.version }}"
check-latest: true

- name: Run GoReleaser
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/test-linux-pr.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/test-linux-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Run Tests (Linux) [on pull request]

# On Linux, we run tests in a custom container image. However, on a pull
# request, we cannot build and push a newer version of that image. Rather
# than make the tests wait on the builds in build-and-test.yml, we trigger
# them immediately using the most recent container image that was built.

on:
pull_request:
repository_dispatch:
types:
- dispatch-build
workflow_dispatch:

jobs:
run-tests:
name: Linux
uses: ./.github/workflows/test-linux.yml
with:
image: hub.opensciencegrid.org/pelican_platform/pelican-test:latest-itb
207 changes: 120 additions & 87 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
---
name: Run Tests (Linux)

# This workflow is intended to be called from other workflows, such as
# build-and-test.yml and test-linux-pr.yml.
# Unlike the macOS and Windows workflows, there is no direct trigger for
# this workflow, because it depends on the container image in which all the
# tests will be run.
#
# The workflows that trigger this one include:
#
# - build-and-test.yml
# - test-linux-pr.yml

on:
workflow_call:
Expand All @@ -11,7 +18,8 @@ on:
type: string

jobs:
test:
run-tests:
name: Linux (${{ matrix.binary_name }})
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
Expand All @@ -26,87 +34,112 @@ jobs:
coverprofile: coverage-server.out
tags: lotman
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0 # GoReleaser needs history to look up the previous tag, and so on
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: "web_ui/frontend/package.json"
cache: "npm"
cache-dependency-path: "web_ui/frontend/package-lock.json"
- name: Cache Next.js
uses: actions/cache@v4
with:
# Reference: https://nextjs.org/docs/pages/guides/ci-build-caching#github-actions
path: |
~/.npm
${{ github.workspace }}/web_ui/frontend/.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: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
check-latest: true
- name: Install gotestsum
run: |
go install gotest.tools/gotestsum@latest
# Ensure that ~/go/bin is in PATH for subsequent steps.
echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Test
env:
JUNIT_FILE: junit-${{ matrix.binary_name }}.xml
run: |
echo "::group::Building web UI"
make web-build
echo "::endgroup::"
gotestsum --format pkgname-and-test-fails --hide-summary=output --junitfile "$JUNIT_FILE" -- -p=4 -timeout 15m -coverpkg=./... -covermode=count -coverprofile=${{ matrix.coverprofile }} -tags=${{ matrix.tags }} ./...
- name: Upload junit report
if: always()
uses: actions/upload-artifact@v4
with:
name: junit-${{ matrix.binary_name }}-linux
path: junit-${{ matrix.binary_name }}.xml
- name: Publish JUnit summary
if: always()
uses: test-summary/action@v2
with:
paths: junit-${{ matrix.binary_name }}.xml
- name: Get total code coverage
if: github.event_name == 'pull_request'
id: cc
run: |
set -x
cc_total=`go tool cover -func=${{ matrix.coverprofile }} | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "cc_total=$cc_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}}'%' >> $GITHUB_STEP_SUMMARY
- name: Mark the checkout as safe
# This is required by the GoReleaser build below and subsequent tests.
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: build --single-target --clean --snapshot
- name: Copy the pelican binary for the end-to-end tests
run: |
cp dist/${{ matrix.binary_name }}_linux_amd64_v1/${{ matrix.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
- name: Run end-to-end test for site-local cache standup
run: ./github_scripts/site_local_cache_test.sh
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0 # GoReleaser needs history to look up the previous tag, and so on

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: "web_ui/frontend/package.json"
cache: "npm"
cache-dependency-path: "web_ui/frontend/package-lock.json"
check-latest: true

- name: Cache Next.js
uses: actions/cache@v4
with:
# Reference: https://nextjs.org/docs/pages/guides/ci-build-caching#github-actions
path: |
~/.npm
${{ github.workspace }}/web_ui/frontend/.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', '!**/node_modules/**') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-

- name: Set Go version
# Determine the string to use in setup-go's "go-version" input.
id: go-version
run: |
version=$(grep -E '^go[[:space:]]*[0-9]+\.[0-9]+' go.mod | grep -oE '[0-9]+\.[0-9]+')
echo "version=${version}.x" >> $GITHUB_OUTPUT

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "${{ steps.go-version.outputs.version }}"
check-latest: true

- name: Install gotestsum
run: |
go install gotest.tools/gotestsum@latest
# Ensure that ~/go/bin is in PATH for subsequent steps.
echo "$HOME/go/bin" >> $GITHUB_PATH

- name: Run "go test"
env:
JUNIT_FILE: junit-${{ matrix.binary_name }}.xml
run: |
echo "::group::Building web UI"
make web-build
echo "::endgroup::"
gotestsum --format pkgname-and-test-fails --hide-summary=output --junitfile "$JUNIT_FILE" -- -p=4 -timeout=15m -coverpkg=./... -covermode=count -coverprofile=${{ matrix.coverprofile }} -tags=${{ matrix.tags }} ./...

- name: Upload JUnit report
if: always()
uses: actions/upload-artifact@v4
with:
name: junit-${{ matrix.binary_name }}-${{ runner.os }}
path: junit-${{ matrix.binary_name }}.xml
overwrite: true # allow the workflow to be re-run, e.g., for flakey tests

- name: Publish JUnit summary
if: always()
uses: test-summary/action@v2
with:
paths: junit-${{ matrix.binary_name }}.xml

- name: Get total code coverage
if: github.event_name == 'pull_request'
id: cc
run: |
set -x
cc_total=`go tool cover -func=${{ matrix.coverprofile }} | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "cc_total=$cc_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 }}%' >> $GITHUB_STEP_SUMMARY

- name: Mark the checkout as safe
# Because we're using a custom container image to run this workflow,
# we trigger Git's "dubious ownership" warning when trying to interact
# with the checkout, unless we mark it as "safe".
run: |
# NOTE: Refer to '${{ github.repository }}' in workflow step
# definitions, but '$GITHUB_WORKSPACE' in scripts.
git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: build --single-target --clean --snapshot

- name: Copy the pelican binary for the end-to-end tests
run: |
cp dist/${{ matrix.binary_name }}_linux_amd64_v1/${{ matrix.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
- name: Run end-to-end test for site-local cache standup
run: ./github_scripts/site_local_cache_test.sh
Loading
Loading