1+ ---
12name : Run Tests (Linux)
23
3- # This workflow is intended to be called from other workflows, such as
4- # build-and-test.yml and test-linux-pr.yml.
4+ # Unlike the macOS and Windows workflows, there is no direct trigger for
5+ # this workflow, because it depends on the container image in which all the
6+ # tests will be run.
7+ #
8+ # The workflows that trigger this one include:
9+ #
10+ # - build-and-test.yml
11+ # - test-linux-pr.yml
512
613on :
714 workflow_call :
1118 type : string
1219
1320jobs :
14- test :
21+ run-tests :
22+ name : Linux (${{ matrix.binary_name }})
1523 runs-on : ubuntu-latest
1624 container :
1725 image : ${{ inputs.image }}
@@ -26,87 +34,112 @@ jobs:
2634 coverprofile : coverage-server.out
2735 tags : lotman
2836 steps :
29- - name : Checkout repository
30- uses : actions/checkout@v6
31- with :
32- fetch-depth : 0 # GoReleaser needs history to look up the previous tag, and so on
33- - name : Set up Node.js
34- uses : actions/setup-node@v6
35- with :
36- node-version-file : " web_ui/frontend/package.json"
37- cache : " npm"
38- cache-dependency-path : " web_ui/frontend/package-lock.json"
39- - name : Cache Next.js
40- uses : actions/cache@v4
41- with :
42- # Reference: https://nextjs.org/docs/pages/guides/ci-build-caching#github-actions
43- path : |
44- ~/.npm
45- ${{ github.workspace }}/web_ui/frontend/.next/cache
46- # Generate a new cache whenever packages or source files change.
47- key : ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
48- # If source files changed but packages didn't, rebuild from a prior cache.
49- restore-keys : |
50- ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
51- - name : Set up Go
52- uses : actions/setup-go@v6
53- with :
54- go-version-file : " go.mod"
55- check-latest : true
56- - name : Install gotestsum
57- run : |
58- go install gotest.tools/gotestsum@latest
59- # Ensure that ~/go/bin is in PATH for subsequent steps.
60- echo "$HOME/go/bin" >> $GITHUB_PATH
61- - name : Test
62- env :
63- JUNIT_FILE : junit-${{ matrix.binary_name }}.xml
64- run : |
65- echo "::group::Building web UI"
66- make web-build
67- echo "::endgroup::"
68- 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 }} ./...
69- - name : Upload junit report
70- if : always()
71- uses : actions/upload-artifact@v4
72- with :
73- name : junit-${{ matrix.binary_name }}-linux
74- path : junit-${{ matrix.binary_name }}.xml
75- - name : Publish JUnit summary
76- if : always()
77- uses : test-summary/action@v2
78- with :
79- paths : junit-${{ matrix.binary_name }}.xml
80- - name : Get total code coverage
81- if : github.event_name == 'pull_request'
82- id : cc
83- run : |
84- set -x
85- cc_total=`go tool cover -func=${{ matrix.coverprofile }} | grep total | grep -Eo '[0-9]+\.[0-9]+'`
86- echo "cc_total=$cc_total" >> $GITHUB_OUTPUT
87- - name : Add coverage information to action summary
88- if : github.event_name == 'pull_request'
89- run : echo 'Code coverage ' ${{steps.cc.outputs.cc_total}}'%' >> $GITHUB_STEP_SUMMARY
90- - name : Mark the checkout as safe
91- # This is required by the GoReleaser build below and subsequent tests.
92- run : |
93- git config --global --add safe.directory "$GITHUB_WORKSPACE"
94- - name : Run GoReleaser
95- uses : goreleaser/goreleaser-action@v6
96- with :
97- distribution : goreleaser
98- version : latest
99- args : build --single-target --clean --snapshot
100- - name : Copy the pelican binary for the end-to-end tests
101- run : |
102- cp dist/${{ matrix.binary_name }}_linux_amd64_v1/${{ matrix.binary_name }} ./pelican
103- - name : Run integration tests
104- run : ./github_scripts/citests.sh
105- - name : Run end-to-end test for object get/put
106- run : ./github_scripts/get_put_test.sh
107- - name : Run end-to-end test for director stat
108- run : ./github_scripts/stat_test.sh
109- - name : Run end-to-end test for --version flag
110- run : ./github_scripts/version_test.sh
111- - name : Run end-to-end test for site-local cache standup
112- run : ./github_scripts/site_local_cache_test.sh
37+ - name : Checkout repository
38+ uses : actions/checkout@v6
39+ with :
40+ fetch-depth : 0 # GoReleaser needs history to look up the previous tag, and so on
41+
42+ - name : Set up Node.js
43+ uses : actions/setup-node@v6
44+ with :
45+ node-version-file : " web_ui/frontend/package.json"
46+ cache : " npm"
47+ cache-dependency-path : " web_ui/frontend/package-lock.json"
48+ check-latest : true
49+
50+ - name : Cache Next.js
51+ uses : actions/cache@v4
52+ with :
53+ # Reference: https://nextjs.org/docs/pages/guides/ci-build-caching#github-actions
54+ path : |
55+ ~/.npm
56+ ${{ github.workspace }}/web_ui/frontend/.next/cache
57+ # Generate a new cache whenever packages or source files change.
58+ key : ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx', '!**/node_modules/**') }}
59+ # If source files changed but packages didn't, rebuild from a prior cache.
60+ restore-keys : |
61+ ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
62+
63+ - name : Set Go version
64+ # Determine the string to use in setup-go's "go-version" input.
65+ id : go-version
66+ run : |
67+ version=$(grep -E '^go[[:space:]]*[0-9]+\.[0-9]+' go.mod | grep -oE '[0-9]+\.[0-9]+')
68+ echo "version=${version}.x" >> $GITHUB_OUTPUT
69+
70+ - name : Set up Go
71+ uses : actions/setup-go@v6
72+ with :
73+ go-version : " ${{ steps.go-version.outputs.version }}"
74+ check-latest : true
75+
76+ - name : Install gotestsum
77+ run : |
78+ go install gotest.tools/gotestsum@latest
79+ # Ensure that ~/go/bin is in PATH for subsequent steps.
80+ echo "$HOME/go/bin" >> $GITHUB_PATH
81+
82+ - name : Run "go test"
83+ env :
84+ JUNIT_FILE : junit-${{ matrix.binary_name }}.xml
85+ run : |
86+ echo "::group::Building web UI"
87+ make web-build
88+ echo "::endgroup::"
89+ 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 }} ./...
90+
91+ - name : Upload JUnit report
92+ if : always()
93+ uses : actions/upload-artifact@v4
94+ with :
95+ name : junit-${{ matrix.binary_name }}-${{ runner.os }}
96+ path : junit-${{ matrix.binary_name }}.xml
97+ overwrite : true # allow the workflow to be re-run, e.g., for flakey tests
98+
99+ - name : Publish JUnit summary
100+ if : always()
101+ uses : test-summary/action@v2
102+ with :
103+ paths : junit-${{ matrix.binary_name }}.xml
104+
105+ - name : Get total code coverage
106+ if : github.event_name == 'pull_request'
107+ id : cc
108+ run : |
109+ set -x
110+ cc_total=`go tool cover -func=${{ matrix.coverprofile }} | grep total | grep -Eo '[0-9]+\.[0-9]+'`
111+ echo "cc_total=$cc_total" >> $GITHUB_OUTPUT
112+
113+ - name : Add coverage information to action summary
114+ if : github.event_name == 'pull_request'
115+ run : echo 'Code coverage ${{ steps.cc.outputs.cc_total }}%' >> $GITHUB_STEP_SUMMARY
116+
117+ - name : Mark the checkout as safe
118+ # Because we're using a custom container image to run this workflow,
119+ # we trigger Git's "dubious ownership" warning when trying to interact
120+ # with the checkout, unless we mark it as "safe".
121+ run : |
122+ # NOTE: Refer to '${{ github.repository }}' in workflow step
123+ # definitions, but '$GITHUB_WORKSPACE' in scripts.
124+ git config --global --add safe.directory "$GITHUB_WORKSPACE"
125+
126+ - name : Run GoReleaser
127+ uses : goreleaser/goreleaser-action@v6
128+ with :
129+ distribution : goreleaser
130+ version : latest
131+ args : build --single-target --clean --snapshot
132+
133+ - name : Copy the pelican binary for the end-to-end tests
134+ run : |
135+ cp dist/${{ matrix.binary_name }}_linux_amd64_v1/${{ matrix.binary_name }} ./pelican
136+ - name : Run integration tests
137+ run : ./github_scripts/citests.sh
138+ - name : Run end-to-end test for object get/put
139+ run : ./github_scripts/get_put_test.sh
140+ - name : Run end-to-end test for director stat
141+ run : ./github_scripts/stat_test.sh
142+ - name : Run end-to-end test for --version flag
143+ run : ./github_scripts/version_test.sh
144+ - name : Run end-to-end test for site-local cache standup
145+ run : ./github_scripts/site_local_cache_test.sh
0 commit comments