Debian Codegraph @

uni-global/.github/workflows/integrate.yml

raw
1 # main only
2
3 name: Integrate
4
5 on:
6 push:
7 branches: [main]
8
9 env:
10 FORCE_COLOR: 1
11
12 jobs:
13 linuxNode14:
14 name: "[Linux] Node.js v14: Unit tests"
15 runs-on: ubuntu-latest
16 steps:
17 - name: Checkout repository
18 uses: actions/checkout@v2
19
20 - name: Retrieve dependencies from cache
21 id: cacheNpm
22 uses: actions/cache@v2
23 with:
24 path: |
25 ~/.npm
26 node_modules
27 key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
28 restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}-
29
30 - name: Install Node.js and npm
31 uses: actions/setup-node@v1
32 with:
33 node-version: 14.x
34
35 - name: Install dependencies
36 if: steps.cacheNpm.outputs.cache-hit != 'true'
37 run: |
38 npm update --no-save
39 npm update --save-dev --no-save
40 - name: Unit tests
41 run: npm test -- -b
42
43 windowsNode14:
44 name: "[Windows] Node.js v14: Unit tests"
45 runs-on: windows-latest
46 steps:
47 - name: Checkout repository
48 uses: actions/checkout@v2
49
50 - name: Retrieve dependencies from cache
51 id: cacheNpm
52 uses: actions/cache@v2
53 with:
54 path: |
55 ~/.npm
56 node_modules
57 key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
58 restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}-
59
60 - name: Install Node.js and npm
61 uses: actions/setup-node@v1
62 with:
63 node-version: 14.x
64
65 - name: Install dependencies
66 if: steps.cacheNpm.outputs.cache-hit != 'true'
67 run: |
68 npm update --no-save
69 npm update --save-dev --no-save
70 - name: Unit tests
71 run: npm test -- -b
72
73 linuxNode16:
74 name: "[Linux] Node.js 16: Unit tests on npm package"
75 runs-on: ubuntu-latest
76 steps:
77 - name: Checkout repository
78 uses: actions/checkout@v2
79
80 - name: Retrieve dependencies from cache
81 id: cacheNpm
82 uses: actions/cache@v2
83 with:
84 path: |
85 ~/.npm
86 node_modules
87 key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
88 restore-keys: npm-v16-${{ runner.os }}-${{ github.ref }}-
89
90 - name: Install Node.js and npm
91 uses: actions/setup-node@v1
92 with:
93 node-version: 16.x
94
95 - name: Install dependencies
96 if: steps.cacheNpm.outputs.cache-hit != 'true'
97 run: |
98 npm update --no-save
99 npm update --save-dev --no-save
100
101 - name: Build local package
102 run: npm pack
103
104 - name: Unit tests on npm package
105 run: |
106 NAME=`cat package.json | grep '"name": "' | grep -oE ": .*" | grep -oE '[^: ",]+'`
107 VERSION=`cat package.json | grep '"version": "' | grep -oE ": .*" | grep -oE '[^: ",]+'`
108 tar zxf "${NAME}-${VERSION}.tgz"
109 cp -R test "package"
110 ln -s "$(pwd)"/node_modules "package/node_modules"
111 cd "package"
112 npm test -- -b
113
114 linuxNode12:
115 name: "[Linux] Node.js v12: Unit tests with coverage"
116 runs-on: ubuntu-latest
117 steps:
118 - name: Checkout repository
119 uses: actions/checkout@v2
120
121 - name: Retrieve dependencies from cache
122 id: cacheNpm
123 uses: actions/cache@v2
124 with:
125 path: |
126 ~/.npm
127 node_modules
128 key: npm-v12-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
129 restore-keys: npm-v12-${{ runner.os }}-${{ github.ref }}-
130
131 - name: Install Node.js and npm
132 uses: actions/setup-node@v1
133 with:
134 node-version: 12.x
135
136 - name: Install dependencies
137 if: steps.cacheNpm.outputs.cache-hit != 'true'
138 run: |
139 npm update --no-save
140 npm update --save-dev --no-save
141 - name: Unit tests
142 run: npm run coverage
143 - name: Push coverage
144 run: npx codecov
145
146 tagIfNewVersion:
147 name: Tag if new version
148 runs-on: ubuntu-latest
149 needs: [linuxNode14, linuxNode12, linuxNode16, windowsNode14]
150 steps:
151 - name: Checkout repository
152 uses: actions/checkout@v2
153 with:
154 # Ensure to have complete history of commits pushed with given push operation
155 # It's loose and imperfect assumption that no more than 30 commits will be pushed at once
156 fetch-depth: 30
157 # Tag needs to be pushed with real user token, otherwise pushed tag won't trigger the actions workflow
158 # Hence we're passing 'serverless-ci' user authentication token
159 token: ${{ secrets.USER_GITHUB_TOKEN }}
160 - name: Tag if new version
161 if: github.event.before != '0000000000000000000000000000000000000000' # Skip on first commit
162 run: |
163 NEW_VERSION=`git diff -U0 ${{ github.event.before }} package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
164 if [ -n "$NEW_VERSION" ];
165 then
166 git tag v$NEW_VERSION
167 git push --tags
168 fi