Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move ci to github actions #1763

Merged
merged 1 commit into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions .circleci/config.yml

This file was deleted.

240 changes: 240 additions & 0 deletions .github/workflows/ci.yml
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/[email protected]
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/[email protected]
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

53 changes: 53 additions & 0 deletions .github/workflows/publish-release-build.yml
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"
28 changes: 0 additions & 28 deletions .github/workflows/publish_build.yml

This file was deleted.

Loading