Skip to content

Commit 45d28c8

Browse files
👶🏽 hello there my sweet runner (#3)
* 👶 hello there my sweet runner * Make executable * Update eslint configuration for breaking prettier change
1 parent f239ceb commit 45d28c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+9183
-0
lines changed

Diff for: .dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dist
2+
node_modules
3+
.git
4+
./run-in-docker.sh
5+
Dockerfile
6+
dev.Dockerfile

Diff for: .eslintignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bin/*
2+
dist/*
3+
docs/*
4+
node_modules/*
5+
production_node_modules/*
6+
test/fixtures/*
7+
tmp/*
8+
jest.config.js

Diff for: .eslintrc

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"project": "./tsconfig.json",
6+
"ecmaVersion": 6,
7+
"sourceType": "module",
8+
"ecmaFeatures": {
9+
"modules": true
10+
}
11+
},
12+
"env": {
13+
"es6": true,
14+
"node": true
15+
},
16+
"extends": [
17+
"eslint:recommended",
18+
"plugin:@typescript-eslint/eslint-recommended",
19+
"plugin:@typescript-eslint/recommended",
20+
"prettier",
21+
"plugin:import/errors",
22+
"plugin:import/warnings",
23+
"plugin:import/typescript"
24+
],
25+
"rules": {
26+
"@typescript-eslint/explicit-function-return-type": [
27+
"warn",
28+
{
29+
"allowExpressions": false,
30+
"allowTypedFunctionExpressions": true,
31+
"allowHigherOrderFunctions": true
32+
}
33+
],
34+
"@typescript-eslint/explicit-member-accessibility": [
35+
"warn",
36+
{
37+
"accessibility": "no-public",
38+
"overrides": {
39+
"accessors": "explicit",
40+
"constructors": "no-public",
41+
"methods": "explicit",
42+
"properties": "explicit",
43+
"parameterProperties": "off"
44+
}
45+
}
46+
],
47+
"@typescript-eslint/no-inferrable-types": [
48+
"error",
49+
{
50+
"ignoreParameters": true
51+
}
52+
],
53+
"@typescript-eslint/no-non-null-assertion": "off",
54+
"@typescript-eslint/no-parameter-properties": [
55+
"warn",
56+
{
57+
"allows": [
58+
"private",
59+
"protected",
60+
"public",
61+
"private readonly",
62+
"protected readonly",
63+
"public readonly"
64+
]
65+
}
66+
],
67+
"@typescript-eslint/no-unused-vars": "off",
68+
"@typescript-eslint/no-use-before-define": [
69+
"error",
70+
{
71+
"functions": false,
72+
"typedefs": false
73+
}
74+
],
75+
"import/no-unresolved": "off"
76+
}
77+
}

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

Diff for: .github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @exercism/maintainers-admin

Diff for: .github/workflows/ci.js.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This workflow will do a clean install of node dependencies and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: typescript-test-runner / master
5+
6+
on:
7+
push:
8+
branches: [master]
9+
10+
jobs:
11+
precheck:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Use Node.js LTS (14.x)
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: 14.x
20+
21+
- name: Install project dependencies
22+
run: yarn install --frozen-lockfile --ignore-scripts
23+
24+
- name: Run exercism/typescript-test-runner ci precheck (lint code)
25+
run: bin/lint.sh
26+
27+
ci:
28+
runs-on: ubuntu-latest
29+
30+
strategy:
31+
matrix:
32+
node-version: [12.x, 14.x, 15.x]
33+
34+
steps:
35+
- uses: actions/checkout@v2
36+
- name: Use Node.js ${{ matrix.node-version }}
37+
uses: actions/setup-node@v1
38+
with:
39+
node-version: ${{ matrix.node-version }}
40+
41+
- name: Install project dependencies
42+
run: yarn install --frozen-lockfile --ignore-scripts
43+
44+
- name: Build the test-runner (using Node ${{ matrix.node-version }})
45+
run: bin/test.sh

Diff for: .github/workflows/codeql.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
name: 'codeql'
7+
8+
on:
9+
push:
10+
branches: [master]
11+
pull_request:
12+
# The branches below must be a subset of the branches above
13+
branches: [master]
14+
schedule:
15+
- cron: '0 14 * * 5'
16+
17+
jobs:
18+
analyze:
19+
runs-on: ubuntu-latest
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
# Override automatic language detection by changing the below list
25+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
26+
language: ['javascript']
27+
# Learn more...
28+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v2
33+
34+
# Initializes the CodeQL tools for scanning.
35+
- name: Initialize CodeQL
36+
uses: github/codeql-action/init@v1
37+
with:
38+
languages: ${{ matrix.language }}
39+
# If you wish to specify custom queries, you can do so here or in a config file.
40+
# By default, queries listed here will override any specified in a config file.
41+
# Prefix the list here with "+" to use these queries and those in the config file.
42+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
43+
44+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
45+
# If this step fails, then you should remove it and run the build manually (see below)
46+
- name: Autobuild
47+
uses: github/codeql-action/autobuild@v1
48+
49+
# ℹ️ Command-line programs to run using the OS shell.
50+
# 📚 https://git.io/JvXDl
51+
52+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
53+
# and modify them (or add more) to build your code if your project
54+
# uses a compiled language
55+
56+
#- run: |
57+
# make bootstrap
58+
# make release
59+
60+
- name: Perform CodeQL Analysis
61+
uses: github/codeql-action/analyze@v1

Diff for: .github/workflows/deploys.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: typescript-test-runner / deploy
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
7+
jobs:
8+
multiple-registries:
9+
runs-on: ubuntu-latest
10+
11+
env:
12+
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # 2.3.4
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@154c24e1f33dbb5865a021c99f1318cfebf27b32 # 1.1.1
20+
21+
- name: Cache Docker layers
22+
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a # 2.1.3
23+
with:
24+
path: /tmp/.buildx-cache
25+
key: ${{ runner.os }}-buildx-${{ github.sha }}
26+
restore-keys: |
27+
${{ runner.os }}-buildx-
28+
29+
- name: Login to DockerHub
30+
uses: docker/login-action@f3364599c6aa293cdc2b8391b1b56d0c30e45c8a # 1.8.0
31+
with:
32+
username: ${{ secrets.DOCKERHUB_USERNAME }}
33+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
34+
35+
- name: Login to ECR
36+
uses: docker/login-action@f3364599c6aa293cdc2b8391b1b56d0c30e45c8a # 1.8.0
37+
with:
38+
registry: ${{ env.ECR_REGISTRY }}
39+
username: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
40+
password: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
41+
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@0db984c1826869dcd0740ff26ff75ff543238fd9 # 2.2.2
44+
with:
45+
context: .
46+
file: ./Dockerfile
47+
push: true
48+
tags: |
49+
${{ github.event.repository.full_name }}:latest
50+
${{ github.event.repository.full_name }}:${{ github.sha }}
51+
${{ env.ECR_REGISTRY }}/${{ github.event.repository.name }}:production
52+
${{ env.ECR_REGISTRY }}/${{ github.event.repository.name }}:${{ github.sha }}
53+
cache-from: type=local,src=/tmp/.buildx-cache
54+
cache-to: type=local,dest=/tmp/.buildx-cache

Diff for: .github/workflows/format-code.yml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: 'Format code'
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
format:
9+
name: 'Format code'
10+
runs-on: ubuntu-latest
11+
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/format')
12+
steps:
13+
- name: 'Post acknowledgement that it will format code'
14+
continue-on-error: true # Never fail the build if this fails
15+
uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # 2.0.0
16+
with:
17+
github-token: ${{ secrets.GITHUB_TOKEN }}
18+
script: |
19+
github.issues.createComment({
20+
issue_number: context.issue.number,
21+
owner: context.repo.owner,
22+
repo: context.repo.repo,
23+
body: 'The "Format code" action has started running.'
24+
})
25+
26+
- name: 'Download PR data'
27+
run: |
28+
PR_DATA="/tmp/pr.json"
29+
30+
jq -r ".issue.pull_request.url" "$GITHUB_EVENT_PATH" | \
31+
xargs curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -o "$PR_DATA" --url
32+
33+
- name: 'Check fork status'
34+
id: fork_status
35+
run: |
36+
IS_FORK="$(jq '.head.repo.fork' "/tmp/pr.json")"
37+
echo "::set-output name=fork::$IS_FORK"
38+
39+
- name: 'Setup SSH deploy key'
40+
if: steps.fork_status.outputs.fork == 'false'
41+
run: |
42+
mkdir ~/.ssh
43+
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
44+
chmod 600 ~/.ssh/id_ed25519
45+
46+
- name: 'Checkout code'
47+
run: |
48+
PR_DATA="/tmp/pr.json"
49+
50+
HEAD_REF=$(jq -r ".head.ref" "$PR_DATA")
51+
52+
if [ ${{ steps.fork_status.outputs.fork }} == "false" ]; then
53+
echo "::debug::Setting up repo using SSH"
54+
HEAD_REPO=$(jq -r '.head.repo.ssh_url' "$PR_DATA")
55+
else
56+
echo "::debug::Setting up repo using HTTPS"
57+
HEAD_REPO=$(jq -r '.head.repo.clone_url | sub("https://"; "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@")' "$PR_DATA")
58+
fi
59+
60+
git clone $HEAD_REPO .
61+
git checkout -b "$HEAD_REF" "origin/$HEAD_REF"
62+
63+
- name: 'Format code'
64+
run: ./bin/format.sh
65+
env:
66+
EXERCISM_PRETTIER_VERSION: '2.2.1'
67+
68+
- name: 'Commit formatted code'
69+
run: |
70+
# Check if there is nothing to commit (i.e. no formatting changes made)
71+
if [ -z "$(git status --porcelain)" ]; then
72+
echo "Code is already formatted correctly"
73+
exit 0
74+
fi
75+
76+
# Setup the git user (required to commit anything)
77+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
78+
git config --global user.name "github-actions[bot]"
79+
80+
# Commit the changes made by prettier
81+
git add .
82+
git commit -m "[CI] Format code"
83+
git push
84+
85+
- name: 'Post acknowledgement that it has formatted the code'
86+
continue-on-error: true # Never fail the build if this fails
87+
uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # 2.0.0
88+
with:
89+
github-token: ${{ secrets.GITHUB_TOKEN }}
90+
script: |
91+
github.issues.createComment({
92+
issue_number: context.issue.number,
93+
owner: context.repo.owner,
94+
repo: context.repo.repo,
95+
body: 'The "Format code" action has finished running.'
96+
})
97+
98+
- name: 'Post reminder to trigger build manually'
99+
continue-on-error: true # Never fail the build if this fails
100+
if: steps.fork_status.outputs.fork == 'true'
101+
uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # 2.0.0
102+
with:
103+
github-token: ${{ secrets.GITHUB_TOKEN }}
104+
script: |
105+
github.issues.createComment({
106+
issue_number: context.issue.number,
107+
owner: context.repo.owner,
108+
repo: context.repo.repo,
109+
body: 'For security reasons, `/format` does not trigger CI builds when the PR has been submitted from a fork. If checks were not passing due to code format, trigger a build to make the required checks pass, through one of the following ways:\n\n- Push an empty commit to this branch: `git commit --allow-empty -m "Trigger builds"`.\n- Close and reopen the PR.\n- Push a regular commit to this branch.'
110+
})

0 commit comments

Comments
 (0)