forked from Cookie-AutoDelete/Cookie-AutoDelete
-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (160 loc) · 6.86 KB
/
continuous-integration-workflow.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI
on:
push:
branches-ignore:
- "_archived__**"
pull_request_target:
branches-ignore:
- "_archived__**"
paths-ignore:
- "**/README.md"
jobs:
pre_info:
name: Initial Checks
runs-on: ubuntu-latest
outputs:
skipCI: ${{ steps.checkci.outputs.result }}
gitSHA: ${{ steps.checkci.outputs.gitSHA }}
steps:
- name: Run CI Check
id: checkci
env:
GH_API: ${{ github.event.repository.commits_url }}
GH_GH: ${{ toJson(github) }}
GH_SHA: ${{ github.event.after }}
PR_FIRSTSHA: ${{ github.event.pull_request.head.sha }}
PR_NUM: ${{ github.event.pull_request.number }}
run: |
echo "Run ID : $GITHUB_RUN_ID"
echo "Event Name: $GITHUB_EVENT_NAME"
echo "PR_NUM : $PR_NUM"
EXP_REF="ds\/(.*)$"
if [[ $GITHUB_REF =~ $EXP_REF ]]; then
GH_REF=${BASH_REMATCH[1]}
fi
REF=$([[ $GITHUB_HEAD_REF ]] && echo $GITHUB_HEAD_REF || echo $GH_REF)
echo "HEAD_REF : $GITHUB_HEAD_REF"
echo "GITHUB_REF: $GITHUB_REF"
echo "GH_REF : $GH_REF"
echo "Branch : $REF"
GH_SHA=$([[ $GH_SHA ]] && echo $GH_SHA || echo $PR_FIRSTSHA)
echo "::set-output name=gitSHA::$GH_SHA"
echo "Commit SHA: $GH_SHA"
echo "PR Head SHA: $PR_FIRSTSHA"
SKIP_A=$([[ "$REF" == l10n_* ]] && echo true || echo false)
echo "Starts With l10n_ : $SKIP_A"
GH_API=${GH_API/'{/sha}'/}
echo "API: $GH_API"
CM=$(curl -s $GH_API/$GH_SHA | jq -r '.commit.message')
echo "Commit Message: $CM"
EXP_SKIP="\[ci skip]"
SKIP_B=$([[ "$CM" =~ $EXP_SKIP ]] && echo true || echo false)
echo "Skip via Commit: $SKIP_B"
RES=$([[ $SKIP_A == true || $SKIP_B == true ]] && echo true || echo false)
echo "Skip CI: $RES"
echo "::set-output name=result::$RES"
all_jobs:
name: Tests, Builds, Coverage
runs-on: ubuntu-latest
needs: pre_info
if: needs.pre_info.outputs.skipCI == 'false'
steps:
- name: Checkout Commit
uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v2.1.5
with:
node-version: "14.x"
- name: Get Node Version
id: node
run: |
echo "Node Version: $(node -v)"
echo "::set-output name=version::$(node -v)"
- name: Cache Node Modules
id: nodeCache
uses: actions/cache@v2
with:
# npm cache files stored in `~/.npm` on Linux
path: ~/.npm
key: ${{ runner.os }}-nodejs-${{ steps.node.outputs.version }}-npm-${{ hashFiles('**/package.json', '**/package-lock.json') }}
- name: Install dependencies from cache (npm --cache-min install)
if: steps.nodeCache.outputs.cache-hit == 'true'
run: npm --cache-min 9999999 install
- name: Install dependencies (npm ci)
if: steps.nodeCache.outputs.cache-hit != 'true'
run: npm ci
- name: Run Tests
run: npm run test -- --verbose
- name: Run Lint
run: npm run lint
- name: Run Build
run: npm run build
env:
GITSHA: ${{ needs.pre_info.outputs.gitSHA }}
- name: Archive Code Coverage Results
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage
- name: Codecov.io Coverage upload
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false
file: ./coverage/*
token: ${{ secrets.CODECOV_TOKEN }} # Optional as it is open source repo
- name: Codecov.io Alternative Coverage Upload
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
env:
PR_NUM: ${{ github.event.pull_request.number }}
CC_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Optional as it is open source repo
run: bash ./.github/codecov_alt.sh $GITHUB_EVENT_PATH
- name: Coveralls.io Coverage Upload
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract zip builds for individual artifact upload
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
id: extbuilds
run: |
for i in *.zip; do echo "${i%.zip}"; done | xargs -I fn unzip fn.zip -d fn
echo "::set-output name=ffdir::$(ls -d *Firefox)"
echo "::set-output name=crdir::$(ls -d *Chrome)"
working-directory: ./builds
- name: Upload Artifact for Mozilla Firefox Build
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: actions/upload-artifact@v2
with:
name: ${{ steps.extbuilds.outputs.ffdir }}
path: builds/${{ steps.extbuilds.outputs.ffdir }}
- name: Upload Artifact for Google Chrome Build
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: actions/upload-artifact@v2
with:
name: ${{ steps.extbuilds.outputs.crdir }}
path: builds/${{ steps.extbuilds.outputs.crdir }}
- name: Hide old PR Build Comments
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: kanga333/comment-hider@v0.1.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create PR Build Comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: peter-evans/create-or-update-comment@v1.4.4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## Pull Request Build: ${{ github.run_id }}
- based on latest commit: ${{ needs.pre_info.outputs.gitSHA }}
Unsigned webextension builds for testing is ready for download!
These test builds are only kept for *up to 90 days* from the date of this post.
It is strongly recommended to use a fresh profile for testing these builds to prevent any kind of modifications to existing data.
### Generating Download Links
- `/get-build` for the latest commit build.
- `/get-build ${{ github.run_id }}` for this specific commit ${{ github.event.after }} build.
---
*When new command comment is posted, please allow a few seconds for the command to be received and processed.*
- :eyes: indicates that command has been received.
- :rocket: indicates that command has been sent for further processing.
- :tada: indicates that command has been executed. Expect a new comment with the result shortly.
*Due to API limitations, generated links will only be valid for one minute!*
reactions: heart