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

Test & deploy with Github Actions #379

Merged
merged 23 commits into from
Jul 5, 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
144 changes: 0 additions & 144 deletions .circleci/config.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [evantahler]
25 changes: 25 additions & 0 deletions .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Docs
on:
push:
branches: [master]

jobs:
publish_docs:
runs-on: ubuntu-latest
container:
image: node
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- run: npm ci
- run: ./bin/deploy-docs
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
directory: gh-pages
force: true
82 changes: 82 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Test
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- run: npm ci
- name: save cache
uses: actions/cache@v2
with:
path: |
node_modules
dist
key: ${{ runner.os }}-cache-${{ hashFiles('**/package-lock.json') }}

lint:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: download cache
uses: actions/cache@v2
with:
path: |
node_modules
dist
key: ${{ runner.os }}-cache-${{ hashFiles('**/package-lock.json') }}
- run: npm run lint

test:
runs-on: ubuntu-latest
needs: build

services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: download cache
uses: actions/cache@v2
with:
path: |
node_modules
dist
key: ${{ runner.os }}-cache-${{ hashFiles('**/package-lock.json') }}
- run: npm rebuild
- run: ./node_modules/.bin/jest --ci --forceExit
env:
REDIS_HOST: localhost
REDIS_PORT: 6379

complete:
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- run: echo "Done!"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The full API documentation for this package is automatically generated from the

[![Nodei stats](https://nodei.co/npm/node-resque.png?downloads=true)](https://npmjs.org/package/node-resque)

[![CircleCI](https://circleci.com/gh/actionhero/node-resque.svg?style=svg)](https://circleci.com/gh/actionhero/node-resque)
![Test](https://github.com/actionhero/node-resque/workflows/Test/badge.svg)

## The Resque Factory (How It Works)

Expand Down
26 changes: 11 additions & 15 deletions __tests__/core/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,27 @@ describe("connection", () => {

test("getKeys returns appropriate keys based on matcher given", async () => {
// seed the DB with keys to test with
await Promise.all(
new Array(25)
.fill(0)
.map((v, i) => i + 1)
.map(async (v) => {
await connection.redis.set(`test-key${v}`, v.toString());
if (v <= 5) {
await connection.redis.set(`test-not-key${v}`, v.toString());
}
})
);

for (const v of new Array(5).fill(0).map((v, i) => i + 1)) {
await connection.redis.set(`test-key${v}`, v.toString());
await connection.redis.set(`test-not-key${v}`, v.toString());
}

await connection.redis.set(`test-key2`, 2);
await connection.redis.set(`test-key3`, 3);
await connection.redis.set(`test-key4`, 4);
await connection.redis.set(`test-key5`, 5);

// sanity checks to confirm keys above are set and exist
expect(await connection.redis.get("test-key1")).toBe("1");
expect(await connection.redis.get("test-key20")).toBe("20");
expect(await connection.redis.get("test-not-key1")).toBe("1");
expect(await connection.redis.get("test-not-key5")).toBe("5");

const foundKeys = await connection.getKeys("test-key*");

expect(foundKeys.length).toBe(25);
expect(foundKeys.length).toBe(5);
expect(foundKeys).toContain("test-key1");
expect(foundKeys).toContain("test-key5");
expect(foundKeys).toContain("test-key20");
expect(foundKeys).toContain("test-key25");
expect(foundKeys).not.toContain("test-key50");
expect(foundKeys).not.toContain("test-not-key1");
expect(foundKeys).not.toContain("test-not-key3");
Expand Down
4 changes: 3 additions & 1 deletion __tests__/core/connectionError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ describe("queue", () => {
const brokenConnection = new Connection(connectionDetails);

brokenConnection.on("error", async (error) => {
expect(error.message).toMatch(/ENOTFOUND|ETIMEDOUT|ECONNREFUSED/);
expect(error.message).toMatch(
/ENOTFOUND|ETIMEDOUT|ECONNREFUSED|EAI_AGAIN/
);
});

try {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/utils/specHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const SpecHelper = {
redis: null,
connectionDetails: {
pkg: pkg,
host: "127.0.0.1",
host: process.env.REDIS_HOST || "127.0.0.1",
password: "",
port: 6379,
database: parseInt(process.env.JEST_WORKER_ID || "0"),
Expand Down
26 changes: 8 additions & 18 deletions bin/deploy-docs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ cd "$(dirname "$0")"
cd ..

## git config
GIT_REMOTE=$(git config remote.origin.url)
GIT_USER_NAME='CircleCI for ActionHero'
GIT_USER_EMAIL='[email protected]'

## Configure a new direcotry to hold the site
rm -rf gh-pages-branch
mkdir gh-pages-branch
cd gh-pages-branch
rm -rf gh-pages
mkdir gh-pages
cd gh-pages
git init
git remote add --fetch origin "$GIT_REMOTE"
if git rev-parse --verify origin/gh-pages > /dev/null 2>&1
then
git checkout gh-pages
Expand All @@ -28,21 +26,13 @@ cd ..
## build master's docs
git checkout "master"
rm -rf docs
mkdir docs
mkdir -p docs
npm run docs
cp -a docs/. gh-pages-branch/
touch gh-pages-branch/.nojekyll
mkdir gh-pages-branch/.circleci && cp .circleci/config.yml gh-pages-branch/.circleci/config.yml
cp images/favicon.ico gh-pages-branch/favicon.ico
cp -a docs/. gh-pages/
touch gh-pages/.nojekyll
cp images/favicon.ico gh-pages/favicon.ico
cp CNAME gh-pages-branch/CNAME

## push it
cd gh-pages-branch
## make the commmit
git add -A
git -c user.name="$GIT_USER_NAME" -c user.email="$GIT_USER_EMAIL" commit --allow-empty -m "deploy static site @ $(date)"
git push --force origin gh-pages
cd ..

## clean up
rm -rf gh-pages-branch
echo "Deployment Complete"
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
maxWorkers: "50%",
testPathIgnorePatterns: ["<rootDir>/__tests__/utils"],
transform: {
"^.+\\.ts?$": "ts-jest",
},
};
9 changes: 0 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@
"typedoc": "^0.21.2",
"typescript": "^4.3.5"
},
"jest": {
"maxWorkers": "50%",
"testPathIgnorePatterns": [
"<rootDir>/__tests__/utils"
],
"transform": {
"^.+\\.ts?$": "ts-jest"
}
},
"scripts": {
"prepare": "npm run build && npm run docs",
"pretest": "npm run lint && npm run build",
Expand Down