Skip to content

Commit

Permalink
Run tests in CI (#390)
Browse files Browse the repository at this point in the history
* Run tests in CI

* Always run CI build

* Add artification extraction script

* Add default changeset stuff

* Adds a changeset
  • Loading branch information
matthewp committed May 18, 2022
1 parent d2fd756 commit f861a4b
Show file tree
Hide file tree
Showing 10 changed files with 13,583 additions and 10,700 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
5 changes: 5 additions & 0 deletions .changeset/chilly-ants-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"haunted": major
---

Deprecates haunted.js and web.js bundles
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
11 changes: 11 additions & 0 deletions .github/extract-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cd artifacts
mkdir -p ../tmp
mv * ../tmp
cd ../tmp
tar -cvzpf artifacts.tar.gz *
mv artifacts.tar.gz ../artifacts.tar.gz
cd ..
tar -xvzpf artifacts.tar.gz
rm -rf artifacts
rm -rf tmp
rm -f artifacts.tar.gz
146 changes: 146 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: CI

on: [push]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16

- name: Cache Node Modules
id: cache-node
uses: actions/cache@v2
with:
path: "**/node_modules"
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}-${{ github.run_id }}
restore-keys: |
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}-${{ github.run_id }}
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}-
- name: Install NPM Dependencies
run: npm ci

- name: Build JavaScript
run: |
npm run build
- name: Upload Package Artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts
path: |
lib/**
if-no-files-found: error

test:
name: 'Test: ${{ matrix.os }} (node@${{ matrix.node_version }})'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node_version: [16]
fail-fast: false
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup node@${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}

- name: Download Build Artifacts
uses: actions/download-artifact@v2

- name: Extract Artifacts
run: ./.github/extract-artifacts.sh

- name: Cache Node Modules
id: cache-node
uses: actions/cache@v2
with:
path: "**/node_modules"
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
restore-keys: |
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
- name: Install NPM Dependencies
run: npm ci
env:
CI: true

- name: Run tests
run: npm run test
env:
CI: true

changelog:
name: Changelog PR or Release
if: ${{ github.ref_name == 'main' && github.repository_owner == 'matthewp' }}
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16

- name: Download Build Artifacts
uses: actions/download-artifact@v2

- name: Extract Artifacts
run: ./.github/extract-artifacts.sh

- name: Cache Node Modules
id: cache-node
uses: actions/cache@v2
with:
path: "**/node_modules"
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}-${{ github.run_id }}
restore-keys: |
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}-${{ github.run_id }}
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}-
- name: Install NPM Dependencies
run: npm ci

- name: Extract package version
id: extract_version
uses: Saionaro/extract-package-version@v1.0.6

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: npm run changeset publish
commit: '[ci] release'
title: '[ci] release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Publish to cdn.spooky.click
# if: steps.changesets.outputs.published == 'true'
# uses: matthewp/cdn-spooky-deploy-action@v4
# with:
# key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# pkg: 'haunted'
# source: 'lib'
# version: ${{ steps.extract_version.outputs.version }}
# symlink: true
# entry: main.js
22 changes: 0 additions & 22 deletions Makefile

This file was deleted.

2 changes: 0 additions & 2 deletions core.js

This file was deleted.

0 comments on commit f861a4b

Please sign in to comment.