Skip to content

Commit

Permalink
ci: add workflow. add utils test and adjust test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Jan 19, 2024
1 parent 7afdf75 commit 302bbc4
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 4 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: 🏎 Test & Publish Adapter

on:
pull_request:
branches:
- main
push:
branches:
- main

# Perform a release using a workflow dispatch
workflow_dispatch:
inputs:
# See https://github.com/hyper63/hyper-ci-bump#inputs for available inputs for the bump action
version:
description: the semver version to bump to
required: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
deno-version: [1.x]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🦕 Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}

- name: ⚡ Run Tests
run: |
deno task test
env:
CI: true

# Run the test suite against a Mongo Instance Self Hosted
# using the mongodb: protocol
#
# This is meant to represent a self-hosted instance of MongoDB
test-integration:
runs-on: ubuntu-latest
strategy:
matrix:
deno-version: [1.x]
redis-version: [7]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🦕 Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}

# Start a Mongo Instance in the local CI runner environment
- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: ${{ matrix.redis-version }}

- name: ⚡ Run Native Integration Tests
run: |
deno task test:integration-native
env:
CI: true
REDIS_URL: http://127.0.0.1:6379

publish:
# Releases are performed via a workflow dispatch
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: [test, test-native-integration-self-hosted, test-native-integration-atlas]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 👀 Env
run: |
echo "Event name: ${{ github.event_name }}"
echo "Git ref: ${{ github.ref }}"
echo "GH actor: ${{ github.actor }}"
echo "SHA: ${{ github.sha }}"
VER=`node --version`; echo "Node ver: $VER"
VER=`npm --version`; echo "npm ver: $VER"
- name: 🤓 Set Git User
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: ✊ Bump
id: bump
uses: hyper63/hyper-ci-bump@main
with:
bump-to: ${{ github.event.inputs.version }}

- name: ⬆️ Push
run: |
git push
git push --tags
- name: 🤖 Create Github Release
if: steps.bump.outputs.tag
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.bump.outputs.tag }}
File renamed without changes.
6 changes: 2 additions & 4 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
"prepare": "deno run -A --no-lock npm:husky@^8 install",
"staged": "deno run -A --no-lock npm:lint-staged@^15",
"cache": "deno cache --lock=deno.lock --lock-write deps.ts dev_deps.ts",
"test": "deno lint && deno fmt --check && deno test -A --unstable",
"test": "deno lint && deno fmt --check && deno test -A --unstable --ignore='*.integration.test.ts'",
"test:integration": "deno test -A --unstable adapter.integration.test.ts",
"test:harness": "deno run --unstable --no-check --no-lock -A ./test/hyper.ts"
},
"fmt": {
"include": ["./"],
"lineWidth": 100,
"singleQuote": true,
"semiColons": false
},
"test": {
"exclude": ["*.integration.test.ts"]
}
}
20 changes: 20 additions & 0 deletions lib/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { assertEquals } from '../dev_deps.ts'

import { createJobKey, createStoreKey } from './utils.ts'

Deno.test('utils', async (t) => {
await t.step('createStoreKey', async (t) => {
await t.step('should create the key', () => {
assertEquals(createStoreKey('prefix', 'foo-queue'), 'prefix_store_{foo-queue}')
})
})

await t.step('createJobKey', async (t) => {
await t.step('should create the key, appending the parts', () => {
assertEquals(
createJobKey('prefix', 'foo-queue', 'READY', 'foo-123'),
'prefix_store_{foo-queue}_job_READY_foo-123',
)
})
})
})

0 comments on commit 302bbc4

Please sign in to comment.