-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💚 Add workflow for Continuous Integration (#1)
- Loading branch information
Showing
10 changed files
with
847 additions
and
111 deletions.
There are no files selected for viewing
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,68 @@ | ||
name: ♾️ Continuous Integration | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
DENO_DIR: deno | ||
DENO_DEPLOY_TOKEN: ${{ secrets.DENO_DEPLOY_TOKEN }} | ||
ENVIRONMENT: ${{ vars.ENVIRONMENT }} | ||
ADMIN_EMAILS: ${{ secrets.ADMIN_EMAILS }} | ||
ADMIN_PASSWORDS: ${{ secrets.ADMIN_PASSWORDS }} | ||
|
||
jobs: | ||
check-code-quality: | ||
name: ✅ Check Code Quality | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 👯♂️ Clone Repository | ||
uses: actions/checkout@v4 | ||
- name: 🦕 Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: vx.x.x | ||
- name: 🗄️ Start Database | ||
uses: MongoCamp/mongodb-github-action@1.2.0 | ||
- name: 🔎 Lint Files | ||
run: deno lint | ||
- name: 🧪 Run Tests | ||
run: deno test --allow-all | ||
|
||
release-preview: | ||
name: 🛰️ Release Preview | ||
needs: check-code-quality | ||
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- name: 👯♂️ Clone Repository | ||
uses: actions/checkout@v4 | ||
- name: 🦕 Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: vx.x.x | ||
- name: 🧰 Install Deploy Tool | ||
run: deno install -A --no-check -r -f https://deno.land/x/deploy/deployctl.ts | ||
- name: 🔥 Deploy | ||
run: deno task deploy | ||
|
||
release-production: | ||
name: 🚀 Release Production | ||
needs: check-code-quality | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- name: 👯♂️ Clone Repository | ||
uses: actions/checkout@v4 | ||
- name: 🦕 Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: vx.x.x | ||
- name: 🧰 Install Deploy Tool | ||
run: deno install -A --no-check -r -f https://deno.land/x/deploy/deployctl.ts | ||
- name: 🔥 Deploy | ||
run: deno task deploy:prod |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Duofiction | ||
|
||
**Duofiction** is a personal project made in my spare time for learning purposes. | ||
**Duofiction** is a personal project made in my spare time for learning purposes. |
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
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 |
---|---|---|
@@ -1,87 +1,38 @@ | ||
import { CliffyCommand } from "@bin/deps.ts"; | ||
import { | ||
CliffyCommand, | ||
existsSync, | ||
type WalkOptions, | ||
walkSync, | ||
} from "../deps.ts"; | ||
import { executeCommand } from "./_utils.ts"; | ||
getDependencyFilePaths, | ||
logger, | ||
removePreviousCache, | ||
runDenoCache, | ||
} from "@bin/commands/_utils.ts"; | ||
|
||
const CacheCommand = new CliffyCommand.Command() | ||
.name("cache") | ||
.description("Cache all dependencies for this project.") | ||
.option("-d, --development [development:boolean]", "", { default: false }) | ||
.option( | ||
"-d, --development [development:boolean]", | ||
"Include development dependencies.", | ||
{ default: false }, | ||
) | ||
.option( | ||
"-c --clean [clean:boolean]", | ||
"Use this option to remove all previous cache.", | ||
{ default: false }, | ||
) | ||
.action(function main(options) { | ||
const paths = getDependencyFiles(options.development); | ||
const paths = getDependencyFilePaths(options.development); | ||
|
||
removePreviousCache(); | ||
if (options.clean) { | ||
removePreviousCache(); | ||
} | ||
|
||
paths.forEach(cacheDependencies); | ||
paths.forEach(runDenoCache.bind(null, options.development)); | ||
|
||
console.info("✅ All dependencies were cached."); | ||
logger.info("✅ All dependencies were cached."); | ||
}); | ||
|
||
if (import.meta.main) { | ||
CacheCommand.parse(Deno.args); | ||
} | ||
|
||
export default CacheCommand; | ||
|
||
function getDependencyFiles(isDevelopment: boolean) { | ||
const paths = [] as string[]; | ||
const skip = [/node_modules/, new RegExp("mod.ts")]; | ||
const opts: WalkOptions = { | ||
includeDirs: false, | ||
exts: [".ts"], | ||
match: [ | ||
/deps\./, | ||
new RegExp(".d.ts"), | ||
], | ||
skip, | ||
}; | ||
|
||
if (!isDevelopment) { | ||
skip.push(/bin\//); | ||
} else { | ||
opts.exts?.push(".mjs"); | ||
opts.match?.push( | ||
new RegExp("prettier.config.mjs"), | ||
new RegExp("scripts.config.ts"), | ||
); | ||
} | ||
|
||
for (const entry of walkSync("./", opts)) { | ||
paths.push(entry.path); | ||
} | ||
|
||
return paths; | ||
} | ||
|
||
function removePreviousCache() { | ||
const denoDir = getCacheFile(); | ||
const nodeModulesDir = "./node_modules"; | ||
|
||
if (existsSync(denoDir)) { | ||
console.info(`ℹ️ Deleting cache on ${denoDir}`); | ||
executeCommand("rm", { args: ["-rf", denoDir] }); | ||
} | ||
|
||
if (existsSync(nodeModulesDir)) { | ||
console.info(`ℹ️ Deleting cache on ${nodeModulesDir}`); | ||
executeCommand("rm", { args: ["-rf", nodeModulesDir] }); | ||
} | ||
} | ||
|
||
function cacheDependencies(path: string) { | ||
console.info(`ℹ️ Caching dependencies for ./${path}`); | ||
const output = executeCommand("deno", { | ||
args: ["cache", "--lock-write", path], | ||
}); | ||
|
||
return output; | ||
} | ||
|
||
function getCacheFile() { | ||
const output = executeCommand("deno", { args: ["info", "--json"] }); | ||
|
||
return JSON.parse(output).denoDir as string; | ||
} |
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,34 @@ | ||
import { CliffyCommand } from "@bin/deps.ts"; | ||
import { | ||
getDependencyFilePaths, | ||
removeOldLockFile, | ||
removePreviousCache, | ||
runDenoCache, | ||
} from "@bin/commands/_utils.ts"; | ||
|
||
const LockCommand = new CliffyCommand.Command() | ||
.name("lock") | ||
.description("Generate the dependencies lock file.") | ||
.option( | ||
"-c --clean [clean:boolean]", | ||
"Use this option to remove all previous cache.", | ||
{ default: false }, | ||
) | ||
.action(function main(options) { | ||
removeOldLockFile(); | ||
const paths = getDependencyFilePaths(false); | ||
|
||
if (options.clean) { | ||
removePreviousCache(); | ||
} | ||
|
||
paths.forEach(runDenoCache.bind(null, true)); | ||
|
||
console.info("✅ Lock file written!"); | ||
}); | ||
|
||
if (import.meta.main) { | ||
LockCommand.parse(Deno.args); | ||
} | ||
|
||
export default LockCommand; |
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
Oops, something went wrong.