Skip to content

Commit c176fc4

Browse files
authored
feat(ci): move to github, work on windows (#928)
1 parent 1ebf389 commit c176fc4

File tree

10 files changed

+833
-792
lines changed

10 files changed

+833
-792
lines changed

.github/workflows/ci.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: ci
2+
on: [push, pull_request]
3+
4+
env:
5+
XDG_CACHE_HOME: ${{ github.workspace }}/.cache
6+
7+
jobs:
8+
9+
test:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [macos-latest, ubuntu-latest, windows-latest]
15+
16+
steps:
17+
- name: Check out Git repository
18+
uses: actions/checkout@v1
19+
20+
- name: Install Node.js
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: 12.x
24+
25+
- name: Restore .cache
26+
uses: actions/cache@v2
27+
id: cache
28+
with:
29+
path: ${{ github.workspace }}/.cache
30+
key: ${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock', '*config.js') }}
31+
restore-keys: |
32+
${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock', '*config.js') }}
33+
${{ runner.os }}-
34+
35+
- name: Restore node_modules
36+
id: yarn-cache
37+
uses: actions/cache@v2
38+
with:
39+
path: node_modules
40+
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
41+
42+
- name: Install dependencies
43+
if: steps.yarn-cache.outputs.cache-hit != 'true'
44+
run: npm run ci:install
45+
46+
- name: Build
47+
run: npm run ci:build
48+
49+
- name: Show build/
50+
run: du -h build/*
51+
52+
- name: Show dist/bundles/*
53+
run: du -h add-on/dist/bundles/*
54+
55+
- name: Test
56+
run: npm run ci:test
57+
58+
- name: Lint
59+
# bundles are too big on Windows and fail addon-lint
60+
# but as long we don't build releases on Windows, can be ignored
61+
if: runner.os != 'Windows'
62+
run: npm run ci:lint
63+
64+
# Persist produced binaries and effective config used for building them
65+
# - this is not for releases, but for quick testing during the dev
66+
# - action artifacts can be downloaded for 90 days, then are removed by github
67+
# - binaries in PRs from forks won't be signed
68+
- name: Attach produced packages to Github Action
69+
uses: actions/upload-artifact@v2
70+
with:
71+
name: built-on-${{ matrix.os }}
72+
path: build/ipfs_companion*.*
73+
if-no-files-found: error
74+
75+
- name: Show Cache
76+
run: du -h ${{ github.workspace }}/.cache/* || true
77+

.travis.yml

-30
This file was deleted.

DEVELOPER-NOTES.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ To run your extension in [Firefox for Android](https://www.mozilla.org/en-US/fir
172172

173173
- [Set up your computer and Android emulator or device](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Developing_WebExtensions_for_Firefox_for_Android#Set_up_your_computer_and_Android_emulator_or_device) (enable Developer Mode, USB debugging, etc.)
174174

175-
Build everything, and switch `add-on/manifest.json` to the Fennec profile:
175+
Build everything, and switch `add-on/manifest.json` to the Firefox profile:
176176

177177
```
178178
npm run dev-build
179-
npm run bundle:fennec
179+
npm run bundle:firefox
180180
```
181181

182182
Then, with your device connected to your development computer, run:

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
[![](https://img.shields.io/github/release/ipfs/ipfs-companion.svg)](https://github.com/ipfs/ipfs-companion/releases/latest)
55
[![](https://img.shields.io/badge/mozilla-reviewed-blue.svg)](https://addons.mozilla.org/en-US/firefox/addon/ipfs-companion/)
66
[![i18n status](https://img.shields.io/badge/i18n-translated-blue.svg)](https://github.com/ipfs-shipyard/ipfs-companion/blob/master/LOCALIZATION-NOTES.md)
7-
[![build-status](https://flat.badgen.net/travis/ipfs-shipyard/ipfs-companion)](https://travis-ci.com/ipfs-shipyard/ipfs-companion)
8-
[![codecov](https://codecov.io/gh/ipfs-shipyard/ipfs-companion/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs-shipyard/ipfs-companion)
97
[![#ipfs-in-web-browsers](https://img.shields.io/badge/irc-%23ipfs--in--web--browsers-808080.svg)](https://webchat.freenode.net/?channels=ipfs-in-web-browsers)
108

119
![Quick runthrough of basic IPFS Companion features](https://gateway.ipfs.io/ipfs/QmeF2v4UFFvZ341ZDQh1xLeeyN4u8Cr9XSTUj6krDEwfrr)

add-on/src/lib/ipfs-client/external.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ log.error = debug('ipfs-companion:client:external:error')
88
const IpfsApi = require('ipfs-http-client')
99

1010
exports.init = async function (opts) {
11-
log(`init with API: ${opts.apiURLString}`)
11+
log(`init with IPFS API at ${opts.apiURLString}`)
1212

1313
const url = opts.apiURL
1414
const protocol = url.protocol.substr(0, url.protocol.length - 1) // http: -> http
@@ -20,5 +20,3 @@ exports.init = async function (opts) {
2020
exports.destroy = async function () {
2121
log('destroy')
2222
}
23-
24-
// TODO: Upgrade to a caching proxy for ipfs-http-client

add-on/src/lib/ipfs-client/index.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,37 @@ const { precache } = require('../precache')
1616
let client
1717

1818
async function initIpfsClient (opts) {
19-
await destroyIpfsClient()
2019
log('init ipfs client')
20+
if (client) return // await destroyIpfsClient()
21+
let backend
2122
switch (opts.ipfsNodeType) {
2223
case 'embedded':
23-
client = embedded
24+
backend = embedded
2425
break
2526
case 'embedded:chromesockets':
26-
client = embeddedWithChromeSockets
27+
backend = embeddedWithChromeSockets
2728
break
2829
case 'external':
29-
client = external
30+
backend = external
3031
break
3132
default:
3233
throw new Error(`Unsupported ipfsNodeType: ${opts.ipfsNodeType}`)
3334
}
34-
35-
const instance = await client.init(opts)
35+
const instance = await backend.init(opts)
3636
easeApiChanges(instance)
3737
_reloadIpfsClientDependents(instance, opts) // async (API is present)
38+
client = backend
3839
return instance
3940
}
4041

4142
async function destroyIpfsClient () {
4243
log('destroy ipfs client')
43-
if (client && client.destroy) {
44-
try {
45-
await client.destroy()
46-
} finally {
47-
client = null
48-
await _reloadIpfsClientDependents() // sync (API stopped working)
49-
}
44+
if (!client) return
45+
try {
46+
await client.destroy()
47+
await _reloadIpfsClientDependents() // sync (API stopped working)
48+
} finally {
49+
client = null
5050
}
5151
}
5252

package.json

+45-46
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,26 @@
1818
"build:copy": "run-s build:copy:*",
1919
"build:copy:src": "shx mkdir -p add-on/dist && shx cp -R add-on/src/* add-on/dist",
2020
"build:js": "run-s build:js:*",
21-
"build:js:webpack": "webpack -p",
21+
"build:js:webpack": "webpack --mode production",
2222
"build:minimize-dist": "shx rm -rf add-on/dist/lib add-on/dist/contentScripts/ add-on/dist/bundles/ipfsProxyContentScriptPayload.bundle.js",
23-
"build:bundle-all": "cross-env RELEASE_CHANNEL=${RELEASE_CHANNEL:=dev} run-s bundle:chromium bundle:brave:$RELEASE_CHANNEL bundle:firefox:$RELEASE_CHANNEL",
24-
"build:rename-artifacts": "./scripts/rename-artifacts.js",
23+
"build:update-manifest": "cross-env ci/update-manifest.sh",
24+
"build:bundle-all": "cross-env run-s bundle:chromium bundle:brave:$RELEASE_CHANNEL bundle:firefox:$RELEASE_CHANNEL",
25+
"build:rename-artifacts": "node scripts/rename-artifacts.js",
26+
"build:reset-manifest": "cross-env RELEASE_CHANNEL=stable ci/update-manifest.sh",
2527
"precache:clean": "shx rm -rf add-on/dist/precache",
2628
"bundle": "run-s bundle:*",
2729
"bundle:chromium": "shx cat add-on/manifest.common.json add-on/manifest.chromium.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/chromium && run-s build:rename-artifacts",
2830
"bundle:firefox": "shx cat add-on/manifest.common.json add-on/manifest.firefox.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/firefox/ && run-s build:rename-artifacts",
29-
"bundle:firefox:dev": "npm run bundle:firefox",
31+
"bundle:firefox:": "npm run bundle:firefox",
3032
"bundle:firefox:stable": "npm run bundle:firefox",
3133
"bundle:firefox:beta": "shx cat add-on/manifest.common.json add-on/manifest.firefox.json add-on/manifest.firefox-beta.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/firefox/ && run-s build:rename-artifacts",
32-
"bundle:fennec": "npm run bundle:firefox",
33-
"bundle:fennec:dev": "npm run bundle:firefox:dev",
34-
"bundle:fennec:stable": "npm run bundle:firefox:stable",
35-
"bundle:fennec:beta": "npm run bundle:firefox:beta",
3634
"bundle:brave": "shx cat add-on/manifest.common.json add-on/manifest.chromium.json add-on/manifest.brave.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/brave/ && run-s build:rename-artifacts",
37-
"bundle:brave:dev": "npm run bundle:brave",
35+
"bundle:brave:": "npm run bundle:brave",
3836
"bundle:brave:stable": "npm run bundle:brave",
3937
"bundle:brave:beta": "shx cat add-on/manifest.common.json add-on/manifest.chromium.json add-on/manifest.brave.json add-on/manifest.brave-beta.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/brave/ && run-s build:rename-artifacts",
4038
"watch": "npm-run-all build:copy --parallel watch:*",
4139
"watch:js": "run-p watch:js:*",
42-
"watch:js:webpack": "webpack --watch --progress -d --devtool inline-source-map --config ./webpack.config.js",
40+
"watch:js:webpack": "webpack --watch --mode development --devtool inline-source-map --config ./webpack.config.js",
4341
"test": "run-s test:*",
4442
"test:functional": " nyc --reporter=lcov --reporter=text mocha --timeout 15000 --require ignore-styles \"test/functional/**/*.test.js\"",
4543
"lint": "run-s lint:*",
@@ -56,13 +54,13 @@
5654
"get-firefox-nightly": "shx test -e ./firefox/firefox || get-firefox -b nightly -e",
5755
"changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s",
5856
"ci": "run-s ci:*",
59-
"ci:install": "npx [email protected].4 install --frozen-lockfile || npx [email protected] install --frozen-lockfile",
60-
"ci:build": "./ci/update-manifest.sh && npx [email protected].4 build",
61-
"ci:test": "npx [email protected].4 test",
62-
"ci:lint": "npx [email protected].4 lint",
57+
"ci:install": "npx [email protected].10 install --frozen-lockfile --no-progress --non-interactive",
58+
"ci:build": "npx [email protected].10 build",
59+
"ci:test": "npx [email protected].10 test",
60+
"ci:lint": "npx [email protected].10 lint",
6361
"beta-build": "docker rmi -f ipfs-companion-beta-build && docker build -t ipfs-companion-beta-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm -it --net=host -e RELEASE_CHANNEL=beta -v $(pwd)/build:/home/node/app/build ipfs-companion-beta-build yarn ci:build",
6462
"release-build": "docker rmi -f ipfs-companion-release-build && docker build -t ipfs-companion-release-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm -it --net=host -e RELEASE_CHANNEL=stable -v $(pwd)/build:/home/node/app/build ipfs-companion-release-build yarn ci:build",
65-
"dev-build": "npx [email protected].4 && npx [email protected].4 build",
63+
"dev-build": "npx [email protected].10 && npx [email protected].10 build",
6664
"yarn-build": "npm run dev-build"
6765
},
6866
"private": true,
@@ -85,79 +83,80 @@
8583
"babel-loader": "8.1.0",
8684
"babel-plugin-syntax-async-generators": "6.13.0",
8785
"chai": "4.2.0",
88-
"cross-env": "6.0.3",
89-
"css-loader": "3.5.3",
86+
"cross-env": "7.0.2",
87+
"css-loader": "4.3.0",
9088
"download-cli": "1.1.1",
91-
"fakefile": "0.0.9",
92-
"file-loader": "6.0.0",
89+
"fakefile": "0.0.10",
90+
"file-loader": "6.1.1",
9391
"firefox-addons-add-update-version": "1.0.1",
9492
"fs-promise": "2.0.3",
9593
"get-firefox": "4.0.0",
96-
"husky": "3.1.0",
94+
"husky": "4.3.0",
9795
"ignore-loader": "0.1.2",
9896
"ignore-styles": "5.0.1",
9997
"ipfs-or-gateway": "2.1.0",
100-
"json": "9.0.6",
98+
"json": "10.0.0",
10199
"mem-storage-area": "1.0.3",
102-
"mini-css-extract-plugin": "0.9.0",
100+
"mini-css-extract-plugin": "1.0.0",
103101
"mocha": "8.1.3",
104102
"npm-run-all": "4.1.5",
105-
"nyc": "14.1.1",
106-
"raw-loader": "4.0.1",
103+
"nyc": "15.1.0",
104+
"raw-loader": "4.0.2",
107105
"request-progress": "3.0.0",
108106
"shx": "0.3.2",
109107
"simple-progress-webpack-plugin": "1.1.2",
110-
"sinon": "9.0.3",
108+
"sinon": "9.2.0",
111109
"sinon-chrome": "3.0.1",
112110
"standard": "14.3.4",
113-
"style-loader": "1.2.1",
114-
"tar": "5.0.5",
115-
"terser": "5.3.2",
116-
"terser-webpack-plugin": "4.2.2",
111+
"style-loader": "2.0.0",
112+
"tar": "6.0.5",
113+
"terser": "5.3.4",
114+
"terser-webpack-plugin": "4.2.3",
117115
"transform-loader": "0.2.4",
118-
"web-ext": "5.1.0",
116+
"web-ext": "5.2.0",
119117
"webpack": "4.44.2",
120118
"webpack-bundle-analyzer": "3.9.0",
121119
"webpack-cli": "3.3.12",
122-
"webpack-merge": "5.1.4"
120+
"webpack-merge": "5.2.0",
121+
"yarn": "1.22.10"
123122
},
124123
"dependencies": {
125-
"@material/switch": "6.0.0",
124+
"@material/switch": "7.0.0",
126125
"browser-process-hrtime": "1.0.0",
127126
"buffer": "5.6.0",
128-
"choo": "7.0.0",
127+
"choo": "7.1.0",
129128
"chrome-dgram": "3.0.5",
130129
"chrome-net": "3.3.4",
131130
"debug": "4.2.0",
132131
"drag-and-drop-files": "0.0.1",
133-
"filesize": "6.0.1",
132+
"filesize": "6.1.0",
134133
"get-port": "5.1.1",
135134
"http-dns": "3.0.1",
136135
"http-node": "1.2.0",
137136
"ipfs": "0.50.2",
138-
"ipfs-css": "1.1.0",
137+
"ipfs-css": "1.2.0",
139138
"ipfs-http-client": "47.0.1",
140139
"ipfs-postmsg-proxy": "3.1.1",
141140
"ipfsx": "0.17.0",
142-
"is-fqdn": "1.0.1",
143-
"is-ipfs": "1.0.3",
141+
"is-fqdn": "2.0.1",
142+
"is-ipfs": "2.0.0",
144143
"it-all": "1.0.4",
145144
"it-concat": "1.0.1",
146145
"it-tar": "1.2.2",
147-
"lru-cache": "5.1.1",
148-
"merge-options": "2.0.0",
149-
"multiaddr": "7.4.3",
150-
"multiaddr-to-uri": "5.0.0",
151-
"p-memoize": "4.0.0",
152-
"p-queue": "6.2.1",
146+
"lru-cache": "6.0.0",
147+
"merge-options": "3.0.3",
148+
"multiaddr": "8.0.0",
149+
"multiaddr-to-uri": "6.0.0",
150+
"p-memoize": "4.0.1",
151+
"p-queue": "6.6.1",
153152
"path-browserify": "1.0.1",
154153
"piggybacker": "2.0.0",
155154
"postmsg-rpc": "2.4.0",
156155
"readable-stream": "3.6.0",
157-
"tachyons": "4.11.1",
158-
"tar-stream": "2.1.2",
156+
"tachyons": "4.12.0",
157+
"tar-stream": "2.1.4",
159158
"timers-browserify-full": "0.0.1",
160-
"uri-to-multiaddr": "3.0.2",
159+
"uri-to-multiaddr": "4.0.0",
161160
"webextension-polyfill": "0.6.0",
162161
"webrtc-ips": "0.1.4"
163162
},

scripts/rename-artifacts.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
const fs = require('fs')
44
const glob = require('glob')
55

6-
const files = glob.sync('./build/*/*.zip')
6+
const files = glob.sync('build/*/*.zip')
77

88
files.map(async file => {
99
const path = file.split('/')
1010
const name = path.pop().split('.zip').shift()
1111
const target = path.pop()
12-
const newFile = `./build/${name}_${target}.zip`
12+
const newFile = `build/${name}_${target}.zip`
1313
// remove old artifact, if exists
1414
if (fs.existsSync(newFile)) fs.unlinkSync(newFile)
1515
// rename artifact
1616
console.log(`${file}${newFile}`)
1717
fs.renameSync(file, newFile)
1818
// remove empty dir
19-
fs.rmdirSync(`./build/${target}`, { recursive: true })
19+
fs.rmdirSync(`build/${target}`, { recursive: true })
2020
})

0 commit comments

Comments
 (0)