Skip to content

Commit

Permalink
feat(ci): move to github, work on windows (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel authored Oct 12, 2020
1 parent 1ebf389 commit c176fc4
Show file tree
Hide file tree
Showing 10 changed files with 833 additions and 792 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: ci
on: [push, pull_request]

env:
XDG_CACHE_HOME: ${{ github.workspace }}/.cache

jobs:

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
- name: Check out Git repository
uses: actions/checkout@v1

- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Restore .cache
uses: actions/cache@v2
id: cache
with:
path: ${{ github.workspace }}/.cache
key: ${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock', '*config.js') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock', '*config.js') }}
${{ runner.os }}-
- name: Restore node_modules
id: yarn-cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: npm run ci:install

- name: Build
run: npm run ci:build

- name: Show build/
run: du -h build/*

- name: Show dist/bundles/*
run: du -h add-on/dist/bundles/*

- name: Test
run: npm run ci:test

- name: Lint
# bundles are too big on Windows and fail addon-lint
# but as long we don't build releases on Windows, can be ignored
if: runner.os != 'Windows'
run: npm run ci:lint

# Persist produced binaries and effective config used for building them
# - this is not for releases, but for quick testing during the dev
# - action artifacts can be downloaded for 90 days, then are removed by github
# - binaries in PRs from forks won't be signed
- name: Attach produced packages to Github Action
uses: actions/upload-artifact@v2
with:
name: built-on-${{ matrix.os }}
path: build/ipfs_companion*.*
if-no-files-found: error

- name: Show Cache
run: du -h ${{ github.workspace }}/.cache/* || true

30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions DEVELOPER-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ To run your extension in [Firefox for Android](https://www.mozilla.org/en-US/fir
- [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.)
Build everything, and switch `add-on/manifest.json` to the Fennec profile:
Build everything, and switch `add-on/manifest.json` to the Firefox profile:
```
npm run dev-build
npm run bundle:fennec
npm run bundle:firefox
```
Then, with your device connected to your development computer, run:
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
[![](https://img.shields.io/github/release/ipfs/ipfs-companion.svg)](https://github.com/ipfs/ipfs-companion/releases/latest)
[![](https://img.shields.io/badge/mozilla-reviewed-blue.svg)](https://addons.mozilla.org/en-US/firefox/addon/ipfs-companion/)
[![i18n status](https://img.shields.io/badge/i18n-translated-blue.svg)](https://github.com/ipfs-shipyard/ipfs-companion/blob/master/LOCALIZATION-NOTES.md)
[![build-status](https://flat.badgen.net/travis/ipfs-shipyard/ipfs-companion)](https://travis-ci.com/ipfs-shipyard/ipfs-companion)
[![codecov](https://codecov.io/gh/ipfs-shipyard/ipfs-companion/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs-shipyard/ipfs-companion)
[![#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)

![Quick runthrough of basic IPFS Companion features](https://gateway.ipfs.io/ipfs/QmeF2v4UFFvZ341ZDQh1xLeeyN4u8Cr9XSTUj6krDEwfrr)
Expand Down
4 changes: 1 addition & 3 deletions add-on/src/lib/ipfs-client/external.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ log.error = debug('ipfs-companion:client:external:error')
const IpfsApi = require('ipfs-http-client')

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

const url = opts.apiURL
const protocol = url.protocol.substr(0, url.protocol.length - 1) // http: -> http
Expand All @@ -20,5 +20,3 @@ exports.init = async function (opts) {
exports.destroy = async function () {
log('destroy')
}

// TODO: Upgrade to a caching proxy for ipfs-http-client
26 changes: 13 additions & 13 deletions add-on/src/lib/ipfs-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@ const { precache } = require('../precache')
let client

async function initIpfsClient (opts) {
await destroyIpfsClient()
log('init ipfs client')
if (client) return // await destroyIpfsClient()
let backend
switch (opts.ipfsNodeType) {
case 'embedded':
client = embedded
backend = embedded
break
case 'embedded:chromesockets':
client = embeddedWithChromeSockets
backend = embeddedWithChromeSockets
break
case 'external':
client = external
backend = external
break
default:
throw new Error(`Unsupported ipfsNodeType: ${opts.ipfsNodeType}`)
}

const instance = await client.init(opts)
const instance = await backend.init(opts)
easeApiChanges(instance)
_reloadIpfsClientDependents(instance, opts) // async (API is present)
client = backend
return instance
}

async function destroyIpfsClient () {
log('destroy ipfs client')
if (client && client.destroy) {
try {
await client.destroy()
} finally {
client = null
await _reloadIpfsClientDependents() // sync (API stopped working)
}
if (!client) return
try {
await client.destroy()
await _reloadIpfsClientDependents() // sync (API stopped working)
} finally {
client = null
}
}

Expand Down
91 changes: 45 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,26 @@
"build:copy": "run-s build:copy:*",
"build:copy:src": "shx mkdir -p add-on/dist && shx cp -R add-on/src/* add-on/dist",
"build:js": "run-s build:js:*",
"build:js:webpack": "webpack -p",
"build:js:webpack": "webpack --mode production",
"build:minimize-dist": "shx rm -rf add-on/dist/lib add-on/dist/contentScripts/ add-on/dist/bundles/ipfsProxyContentScriptPayload.bundle.js",
"build:bundle-all": "cross-env RELEASE_CHANNEL=${RELEASE_CHANNEL:=dev} run-s bundle:chromium bundle:brave:$RELEASE_CHANNEL bundle:firefox:$RELEASE_CHANNEL",
"build:rename-artifacts": "./scripts/rename-artifacts.js",
"build:update-manifest": "cross-env ci/update-manifest.sh",
"build:bundle-all": "cross-env run-s bundle:chromium bundle:brave:$RELEASE_CHANNEL bundle:firefox:$RELEASE_CHANNEL",
"build:rename-artifacts": "node scripts/rename-artifacts.js",
"build:reset-manifest": "cross-env RELEASE_CHANNEL=stable ci/update-manifest.sh",
"precache:clean": "shx rm -rf add-on/dist/precache",
"bundle": "run-s bundle:*",
"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",
"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",
"bundle:firefox:dev": "npm run bundle:firefox",
"bundle:firefox:": "npm run bundle:firefox",
"bundle:firefox:stable": "npm run bundle:firefox",
"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",
"bundle:fennec": "npm run bundle:firefox",
"bundle:fennec:dev": "npm run bundle:firefox:dev",
"bundle:fennec:stable": "npm run bundle:firefox:stable",
"bundle:fennec:beta": "npm run bundle:firefox:beta",
"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",
"bundle:brave:dev": "npm run bundle:brave",
"bundle:brave:": "npm run bundle:brave",
"bundle:brave:stable": "npm run bundle:brave",
"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",
"watch": "npm-run-all build:copy --parallel watch:*",
"watch:js": "run-p watch:js:*",
"watch:js:webpack": "webpack --watch --progress -d --devtool inline-source-map --config ./webpack.config.js",
"watch:js:webpack": "webpack --watch --mode development --devtool inline-source-map --config ./webpack.config.js",
"test": "run-s test:*",
"test:functional": " nyc --reporter=lcov --reporter=text mocha --timeout 15000 --require ignore-styles \"test/functional/**/*.test.js\"",
"lint": "run-s lint:*",
Expand All @@ -56,13 +54,13 @@
"get-firefox-nightly": "shx test -e ./firefox/firefox || get-firefox -b nightly -e",
"changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s",
"ci": "run-s ci:*",
"ci:install": "npx yarn@1.22.4 install --frozen-lockfile || npx yarn@1.22.4 install --frozen-lockfile",
"ci:build": "./ci/update-manifest.sh && npx yarn@1.22.4 build",
"ci:test": "npx yarn@1.22.4 test",
"ci:lint": "npx yarn@1.22.4 lint",
"ci:install": "npx yarn@1.22.10 install --frozen-lockfile --no-progress --non-interactive",
"ci:build": "npx yarn@1.22.10 build",
"ci:test": "npx yarn@1.22.10 test",
"ci:lint": "npx yarn@1.22.10 lint",
"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",
"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",
"dev-build": "npx yarn@1.22.4 && npx yarn@1.22.4 build",
"dev-build": "npx yarn@1.22.10 && npx yarn@1.22.10 build",
"yarn-build": "npm run dev-build"
},
"private": true,
Expand All @@ -85,79 +83,80 @@
"babel-loader": "8.1.0",
"babel-plugin-syntax-async-generators": "6.13.0",
"chai": "4.2.0",
"cross-env": "6.0.3",
"css-loader": "3.5.3",
"cross-env": "7.0.2",
"css-loader": "4.3.0",
"download-cli": "1.1.1",
"fakefile": "0.0.9",
"file-loader": "6.0.0",
"fakefile": "0.0.10",
"file-loader": "6.1.1",
"firefox-addons-add-update-version": "1.0.1",
"fs-promise": "2.0.3",
"get-firefox": "4.0.0",
"husky": "3.1.0",
"husky": "4.3.0",
"ignore-loader": "0.1.2",
"ignore-styles": "5.0.1",
"ipfs-or-gateway": "2.1.0",
"json": "9.0.6",
"json": "10.0.0",
"mem-storage-area": "1.0.3",
"mini-css-extract-plugin": "0.9.0",
"mini-css-extract-plugin": "1.0.0",
"mocha": "8.1.3",
"npm-run-all": "4.1.5",
"nyc": "14.1.1",
"raw-loader": "4.0.1",
"nyc": "15.1.0",
"raw-loader": "4.0.2",
"request-progress": "3.0.0",
"shx": "0.3.2",
"simple-progress-webpack-plugin": "1.1.2",
"sinon": "9.0.3",
"sinon": "9.2.0",
"sinon-chrome": "3.0.1",
"standard": "14.3.4",
"style-loader": "1.2.1",
"tar": "5.0.5",
"terser": "5.3.2",
"terser-webpack-plugin": "4.2.2",
"style-loader": "2.0.0",
"tar": "6.0.5",
"terser": "5.3.4",
"terser-webpack-plugin": "4.2.3",
"transform-loader": "0.2.4",
"web-ext": "5.1.0",
"web-ext": "5.2.0",
"webpack": "4.44.2",
"webpack-bundle-analyzer": "3.9.0",
"webpack-cli": "3.3.12",
"webpack-merge": "5.1.4"
"webpack-merge": "5.2.0",
"yarn": "1.22.10"
},
"dependencies": {
"@material/switch": "6.0.0",
"@material/switch": "7.0.0",
"browser-process-hrtime": "1.0.0",
"buffer": "5.6.0",
"choo": "7.0.0",
"choo": "7.1.0",
"chrome-dgram": "3.0.5",
"chrome-net": "3.3.4",
"debug": "4.2.0",
"drag-and-drop-files": "0.0.1",
"filesize": "6.0.1",
"filesize": "6.1.0",
"get-port": "5.1.1",
"http-dns": "3.0.1",
"http-node": "1.2.0",
"ipfs": "0.50.2",
"ipfs-css": "1.1.0",
"ipfs-css": "1.2.0",
"ipfs-http-client": "47.0.1",
"ipfs-postmsg-proxy": "3.1.1",
"ipfsx": "0.17.0",
"is-fqdn": "1.0.1",
"is-ipfs": "1.0.3",
"is-fqdn": "2.0.1",
"is-ipfs": "2.0.0",
"it-all": "1.0.4",
"it-concat": "1.0.1",
"it-tar": "1.2.2",
"lru-cache": "5.1.1",
"merge-options": "2.0.0",
"multiaddr": "7.4.3",
"multiaddr-to-uri": "5.0.0",
"p-memoize": "4.0.0",
"p-queue": "6.2.1",
"lru-cache": "6.0.0",
"merge-options": "3.0.3",
"multiaddr": "8.0.0",
"multiaddr-to-uri": "6.0.0",
"p-memoize": "4.0.1",
"p-queue": "6.6.1",
"path-browserify": "1.0.1",
"piggybacker": "2.0.0",
"postmsg-rpc": "2.4.0",
"readable-stream": "3.6.0",
"tachyons": "4.11.1",
"tar-stream": "2.1.2",
"tachyons": "4.12.0",
"tar-stream": "2.1.4",
"timers-browserify-full": "0.0.1",
"uri-to-multiaddr": "3.0.2",
"uri-to-multiaddr": "4.0.0",
"webextension-polyfill": "0.6.0",
"webrtc-ips": "0.1.4"
},
Expand Down
6 changes: 3 additions & 3 deletions scripts/rename-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
const fs = require('fs')
const glob = require('glob')

const files = glob.sync('./build/*/*.zip')
const files = glob.sync('build/*/*.zip')

files.map(async file => {
const path = file.split('/')
const name = path.pop().split('.zip').shift()
const target = path.pop()
const newFile = `./build/${name}_${target}.zip`
const newFile = `build/${name}_${target}.zip`
// remove old artifact, if exists
if (fs.existsSync(newFile)) fs.unlinkSync(newFile)
// rename artifact
console.log(`${file}${newFile}`)
fs.renameSync(file, newFile)
// remove empty dir
fs.rmdirSync(`./build/${target}`, { recursive: true })
fs.rmdirSync(`build/${target}`, { recursive: true })
})
Loading

0 comments on commit c176fc4

Please sign in to comment.