114 lines (96 loc) · 3.87 KB
/
build.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
name: Build
on: [ push, pull_request, workflow_dispatch ]
env:
CI_WUI_BRANCH: ${{ vars.CI_WUI_BRANCH }}
CI_WUI_DISABLE_LOCAL_PUBLISH: ${{ vars.CI_WUI_DISABLE_LOCAL_PUBLISH }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v3
with:
path: repo
- name: "Checkout Weaver-UI-Core"
uses: actions/checkout@v3
with:
repository: TAMULib/Weaver-UI-Core
path: weaver-ui
ref: 2.x
# Specify depth of 0 to enable fetching all branches and tags so that the "Use Custom Weaver-UI-Core Repo Version" works.
fetch-depth: 0
- name: "Detect Custom Weaver-UI-Core Repo Version"
continue-on-error: true
if: ${{ env.CI_WUI_BRANCH == '' }}
run: |
cd weaver-ui
export CI_WUI_BRANCH_VERSION=$(grep -so -m 1 '"@wvr/core": "[^"]*"' ../repo/package.json | sed -e 's|"@wvr/core": "||' -e 's|"$||')
export CI_WUI_BRANCH=$(git tag | grep -so -m 1 "^$CI_WUI_BRANCH_VERSION$")
# Some projects prefix their version with a "v".
if [[ $CI_WUI_BRANCH == "" && $CI_WUI_BRANCH_VERSION != "" ]] ; then export CI_WUI_BRANCH=$(git tag | grep -so -m 1 "^v$CI_WUI_BRANCH_VERSION$") ; fi
echo "CI_WUI_BRANCH=$CI_WUI_BRANCH" >> $GITHUB_ENV
- name: "Use Custom Weaver-UI-Core Repo Version"
continue-on-error: true
if: ${{ env.CI_WUI_BRANCH != '' }}
run: |
cd weaver-ui
git reset --hard $CI_WUI_BRANCH
- name: "Run Weaver-UI-Core Docker Compose Registry Image"
run: docker-compose -f $GITHUB_WORKSPACE/weaver-ui/docker-compose.yml up -d registry
- name: "Publish Weaver-UI-Core (@wvr/core)"
if: ${{ env.CI_WUI_DISABLE_LOCAL_PUBLISH != 'true' }}
run: |
cd $GITHUB_WORKSPACE/weaver-ui
npm run publish:local
- name: "Node Cache"
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-cache-node-${{ hashFiles('**/package.json') }}
- name: "Node Modules Cache"
uses: actions/cache@v3
with:
path: $GITHUB_WORKSPACE/repo/node_modules
key: ${{ runner.os }}-cache-node_modules-${{ hashFiles('**/package.json') }}
- name: "Setup Node"
uses: actions/setup-node@v3
with:
node-version: 16
- name: "Setup Java"
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'adopt'
cache: 'maven'
- name: "Maven Test"
env:
NPM_CONFIG_REGISTRY: http://localhost:4873
run: |
cd $GITHUB_WORKSPACE/repo
mvn clean test jacoco:report coveralls:report -DdryRun=true -DtestClient
- name: "Combine Coverage"
run: |
cd $GITHUB_WORKSPACE/repo
cat coverage/lcov.info | node node_modules/coveralls/bin/coveralls.js -s > coverage/coveralls.json
jq 'reduce inputs as $i (.; .source_files += $i.source_files)' target/coveralls.json coverage/coveralls.json > coveralls.json
- name: "Coverage Report"
uses: MikeEdgar/github-action@raw_coverage_file
with:
github-token: ${{ secrets.github_token }}
path-to-file: 'repo/coveralls.json'
coverage-format: raw
- name: "Lighthouse Report"
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
run: |
cd $GITHUB_WORKSPACE/repo
xvfb-run --auto-servernum npm run test:audit
- name: "Deploy GH-Pages"
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
github_token: ${{ secrets.github_token }}
branch: gh-pages
folder: repo/target/gh-pages
clean: true
single_commit: true