-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b8f3b4
commit d76624e
Showing
7 changed files
with
3,999 additions
and
0 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,24 @@ | ||
# .github/workflows/main.yml | ||
name: Run Jest Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: "16" | ||
- run: npm install | ||
- run: npm test -- --ci --reporters=default --reporters=jest-junit | ||
- name: update Airtable | ||
if: always() | ||
run: node ./.scripts/main.js JS ${{github.actor}} https://github.com/${{github.repository}} |
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,130 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* |
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,85 @@ | ||
const axios = require("axios"); | ||
const fs = require("fs"); | ||
const { argv } = require("process"); | ||
const xml2js = require("xml2js"); | ||
|
||
// Constants and configuration | ||
const TOPIC = argv[2]; | ||
const STUDENT_GITHUB = argv[3]; | ||
const STUDENT_REPO = argv[4]; | ||
const JEST_REPORT_PATH = "./junit.xml"; | ||
|
||
// Airtable API functions | ||
const airtableApiServer = axios.create({ | ||
baseURL: `https://airtable-be.vercel.app/`, | ||
}); | ||
|
||
// Jest report parsing | ||
function parseJestReport(xmlContent) { | ||
return new Promise((resolve, reject) => { | ||
xml2js.parseString(xmlContent, (err, result) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
const testsuites = result.testsuites; | ||
const totalTests = parseInt(testsuites.$.tests); | ||
const failedTests = parseInt(testsuites.$.failures); | ||
const passedTests = totalTests - failedTests; | ||
const grade = (passedTests / totalTests) * 100; | ||
|
||
resolve({ totalTests, passedTests, failedTests, grade }); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
const sendDataToServer = async ( | ||
passedTests, | ||
failedTests, | ||
grade, | ||
studentGitHub, | ||
studentRepo | ||
) => { | ||
try { | ||
await airtableApiServer | ||
.post("/", { | ||
passedTests, | ||
failedTests, | ||
grade, | ||
studentGitHub, | ||
studentRepo, | ||
topic: TOPIC, | ||
}) | ||
.then((response) => console.log("Sent Data Successfully")); | ||
} catch (error) { | ||
console.log("error in sending data to server", error); | ||
} | ||
}; | ||
|
||
// Main function | ||
async function main() { | ||
try { | ||
const jestResults = fs.readFileSync(JEST_REPORT_PATH, "utf8"); | ||
const { totalTests, passedTests, failedTests, grade } = | ||
await parseJestReport(jestResults); | ||
|
||
console.log(`Total tests: ${totalTests}`); | ||
console.log(`Passed tests: ${passedTests}`); | ||
console.log(`Failed tests: ${failedTests}`); | ||
console.log(`Grade: ${grade.toFixed(2)}%`); | ||
|
||
await sendDataToServer( | ||
passedTests, | ||
failedTests, | ||
grade.toFixed(2), | ||
STUDENT_GITHUB, | ||
STUDENT_REPO | ||
); | ||
} catch (error) { | ||
console.error("An error occurred:", error.message); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// Run the main function | ||
main(); |
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,67 @@ | ||
// Array of numbers | ||
const numbers = [10, 13, 20, 25, 38, 35, 40]; | ||
|
||
// 1) Using `greaterThanTwentyFive` function that returns a new array containing numbers that are greater than or equal to 25. | ||
const greaterThanTwentyFive = (numbers) => { | ||
// write your code here... | ||
}; | ||
|
||
// 2) Using `divisibleByFive` function return a new array containing numbers that are divisible by 5. | ||
const divisibleByFive = (numbers) => { | ||
// write your code here... | ||
}; | ||
|
||
// 3) Using `squaredNumbers` function return a new array that contains each number squared. | ||
const squaredNumbers = (numbers) => { | ||
// write your code here... | ||
}; | ||
|
||
// 4) Using `doubledNumbers` function return a new array that contains each number multiplied by 2. | ||
const doubledNumbers = (numbers) => { | ||
// write your code here... | ||
}; | ||
|
||
// 5) Using `filteredAndSquared` function return the numbers that are greater than or equal to 20 and then square each of them. | ||
const filteredAndSquared = (numbers) => { | ||
// write your code here... | ||
}; | ||
|
||
// 6) Using `filteredAndTripled` return the numbers that are divisible by 5 and then multiply each of them by 3. | ||
const filteredAndTripled = (numbers) => { | ||
// write your code here... | ||
}; | ||
|
||
// 🌶️🌶️🌶️ Extra | ||
|
||
// 1) Using `logger` function log every element in an array | ||
function logger(array) { | ||
// write your code here... | ||
} | ||
|
||
// 2) using `toCelsius` function return an array of temperatures in Celsius | ||
function toCelsius(temperatures) { | ||
// write your code here... | ||
} | ||
|
||
// 3) using `hottestDays` function return an array of temperatures that exceed the threshold | ||
function hottestDays(temperatures, threshold) { | ||
// write your code here... | ||
} | ||
|
||
// 4) Using `logHottestDays` function log temperatures that exceed the threshold to the console IN DEGREES CELSIUS (hint: you can combine all previous functions) | ||
function logHottestDays(temperatures, threshold) { | ||
// write your code here... | ||
} | ||
|
||
module.exports = { | ||
greaterThanTwentyFive, | ||
divisibleByFive, | ||
squaredNumbers, | ||
doubledNumbers, | ||
filteredAndSquared, | ||
filteredAndTripled, | ||
logger, | ||
toCelsius, | ||
hottestDays, | ||
logHottestDays, | ||
}; |
Oops, something went wrong.