-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: move build to gh action (#1763)
- Loading branch information
Showing
9 changed files
with
526 additions
and
127 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
name: ci | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
XDG_CACHE_HOME: ${{ github.workspace }}/.cache | ||
|
||
jobs: | ||
build: | ||
name: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 15 | ||
|
||
- name: Cache bigger downloads | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ${{ github.workspace }}/.cache | ||
key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
${{ runner.os }}- | ||
- name: Install dependencies | ||
run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm | ||
|
||
# Separate cache for build dir, we reuse it in release publish workflow | ||
- name: Cache build output | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: actions/cache@v2 | ||
id: build-cache | ||
with: | ||
path: build | ||
key: ${{ runner.os }}-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ github.sha }} | ||
- name: Confirm build works | ||
if: steps.build-cache.outputs.cache-hit != 'true' | ||
run: npm run build | ||
|
||
# Persist produced build dir: | ||
# - 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 | ||
- name: Attach produced build to Github Action | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ipfs-webui_${{ github.sha }} | ||
path: build | ||
if-no-files-found: error | ||
|
||
test-unit: | ||
name: 'test:unit' | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 15 | ||
|
||
- name: Cache bigger downloads | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ${{ github.workspace }}/.cache | ||
key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
${{ runner.os }}- | ||
- name: Install dependencies | ||
run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm | ||
|
||
- name: Run unit tests | ||
run: npm run test:unit | ||
|
||
publish-preview: | ||
name: publish preview | ||
needs: build | ||
environment: Deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 15 | ||
|
||
- name: Download build artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ipfs-webui_${{ github.sha }} | ||
path: build | ||
|
||
# pin the built site to ipfs-websites cluster, output the cid as `steps.ipfs.outputs.cid` | ||
# see: https://github.com/ipfs-shipyard/ipfs-github-action | ||
- uses: ipfs-shipyard/ipfs-github-action@v2.0.0 | ||
id: ipfs | ||
with: | ||
path_to_add: build | ||
cluster_host: /dnsaddr/ipfs-websites.collab.ipfscluster.io | ||
cluster_user: ${{ secrets.CLUSTER_USER }} | ||
cluster_password: ${{ secrets.CLUSTER_PASSWORD }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- run: echo ${{ steps.ipfs.outputs.url }} | ||
- run: echo ${{ github.ref }} | ||
|
||
# dev dnslink is updated on each main branch update | ||
- run: npx dnslink-dnsimple --domain dev.webui.ipfs.io --link /ipfs/${{ steps.ipfs.outputs.cid }} | ||
if: github.ref == 'refs/heads/main' | ||
env: | ||
DNSIMPLE_TOKEN: ${{ secrets.DNSIMPLE_TOKEN }} | ||
|
||
# production dnslink is updated on release (during tag build) | ||
- run: npx dnslink-dnsimple --domain webui.ipfs.io --link /ipfs/${{ steps.ipfs.outputs.cid }} | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
env: | ||
DNSIMPLE_TOKEN: ${{ secrets.DNSIMPLE_TOKEN }} | ||
|
||
test-e2e: | ||
name: 'test:e2e' | ||
needs: build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
backend: [js, go] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 15 | ||
|
||
- name: Cache bigger downloads | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ${{ github.workspace }}/.cache | ||
key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
${{ runner.os }}- | ||
- name: Install dependencies | ||
run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm | ||
|
||
- name: Download build artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ipfs-webui_${{ github.sha }} | ||
path: build | ||
|
||
- name: Run E2E against ${{ matrix.backend }}-ipfs | ||
run: E2E_IPFSD_TYPE=${{ matrix.backend }} npm run test:e2e | ||
|
||
# separate check for TS | ||
typecheck: | ||
name: typecheck | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 15 | ||
|
||
- name: Cache bigger downloads | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ${{ github.workspace }}/.cache | ||
key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
${{ runner.os }}- | ||
- name: Install dependencies | ||
run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm | ||
|
||
- name: Fancy Typecheck with GH annotations | ||
uses: gozala/typescript-error-reporter-action@v1.0.8 | ||
with: | ||
project: tsconfig.json | ||
|
||
# make sure local check is also ok | ||
- name: Userland check | ||
run: npm run typecheck | ||
|
||
# separate check for eslint | ||
eslint: | ||
name: eslint | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 15 | ||
|
||
- name: Cache bigger downloads | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ${{ github.workspace }}/.cache | ||
key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
${{ runner.os }}- | ||
- name: Install dependencies | ||
run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm | ||
|
||
- name: ESLint | ||
run: npm run eslint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Publish Binaries | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
env: | ||
XDG_CACHE_HOME: ${{ github.workspace }}/.cache | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Cache bigger downloads | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ${{ github.workspace }}/.cache | ||
key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }} | ||
${{ runner.os }}- | ||
# Reuse tag build | ||
- name: Cache build dir | ||
uses: actions/cache@v2 | ||
id: build-cache | ||
with: | ||
path: build | ||
key: ${{ runner.os }}-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ github.sha }} | ||
- name: Install and Build 🔧 | ||
if: steps.build-cache.outputs.cache-hit != 'true' | ||
run: | | ||
npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm | ||
npm run build | ||
- name: Create archive | ||
run: tar -czf ipfs-webui.tar.gz build/* | ||
|
||
- name: Attach prebuilt archive to Release Notes | ||
uses: skx/github-action-publish-binaries@c881a3f8ffb80b684f367660178d38ceabc065c2 #release-0.15 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
args: "./ipfs-webui.tar.gz" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.