forked from PelicanPlatform/pelican
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (146 loc) · 5.66 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
on: [push, pull_request]
name: Test
permissions:
pull-requests: write
jobs:
test:
strategy:
matrix:
go-version: [1.21.x]
os: [macos-12, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- 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
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- 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', '!**/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: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Install Mac OS X Dependencies
run: ./github_scripts/osx_install.sh
if: runner.os == 'macOS'
- name: Test OS X
if: runner.os == 'macOS'
run: |
make web-build
go test -v -coverpkg=./... -coverprofile=coverage.out -covermode=count ./...
- name: Test
if: runner.os != 'macOS'
run: |
make web-build
go test ./...
- name: Run GoReleaser for Non-Ubuntu
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
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 for --version flag
run: ./github_scripts/version_test.sh