-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4253 from coralproject/develop
v8.2.0
- Loading branch information
Showing
32 changed files
with
807 additions
and
195 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 |
---|---|---|
|
@@ -7,6 +7,8 @@ on: | |
|
||
env: | ||
IMAGE_REPOSITORY: 'gcr.io/the-coral-project/coral' | ||
IMAGE_CACHE_REPOSITORY: 'coralproject/ci' | ||
DOCKERHUB_USERNAME: 'coralproject' | ||
|
||
|
||
jobs: | ||
|
@@ -16,7 +18,10 @@ jobs: | |
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
uses: webfactory/[email protected] | ||
with: | ||
|
@@ -28,6 +33,12 @@ jobs: | |
registry: gcr.io | ||
username: _json_key | ||
password: ${{ secrets.GCR_JSON_KEY }} | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ env.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- | ||
name: Define SHORT_SHA with commit short sha | ||
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | ||
|
@@ -90,20 +101,24 @@ jobs: | |
# Build tag push the image after a merge to develop | ||
- | ||
name: Build, Tag, Push | ||
uses: docker/build-push-action@v3 | ||
uses: docker/build-push-action@v4 | ||
if: github.ref == 'refs/heads/develop' | ||
with: | ||
push: true | ||
tags: ${{ env.IMAGE_REPOSITORY }}:develop-latest | ||
build-args: | | ||
REVISION_HASH=${GITHUB_SHA} | ||
cache-from: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-develop | ||
cache-to: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-develop | ||
# Build tag push the release candidate image when the branch name begins with release- | ||
- | ||
name: Build, Tag, Push RC | ||
uses: docker/build-push-action@v3 | ||
uses: docker/build-push-action@v4 | ||
if: startsWith( github.ref, 'refs/heads/release-') | ||
with: | ||
push: true | ||
tags: ${{ env.IMAGE_REPOSITORY }}:${{ github.ref_name }}-${{ env.SHORT_SHA }} | ||
build-args: | | ||
REVISION_HASH=${GITHUB_SHA} | ||
cache-from: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-release | ||
cache-to: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-release |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ env: | |
DOCKERHUB_USERNAME: 'coralproject' | ||
GOOGLE_CLOUD_BUCKET: 'coral-cdn' | ||
IMAGE_REPOSITORY: 'coralproject/talk' | ||
IMAGE_CACHE_REPOSITORY: 'coralproject/ci' | ||
SENTRY_ORG: 'voxmedia' | ||
SENTRY_PROJECT: 'coral' | ||
|
||
|
@@ -20,7 +21,10 @@ jobs: | |
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
uses: webfactory/[email protected] | ||
with: | ||
|
@@ -118,28 +122,34 @@ jobs: | |
echo "PATCH_TAG=${MAJOR}.${MINOR}.${PATCH}" >> $GITHUB_ENV | ||
- | ||
name: Build, Tag, Push Major Tag | ||
uses: docker/build-push-action@v3 | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ${{ env.IMAGE_REPOSITORY }}:${{ env.MAJOR_TAG }} | ||
build-args: | | ||
REVISION_HASH=${{ env.GITHUB_SHA }} | ||
cache-from: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-major | ||
cache-to: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-major | ||
- | ||
name: Build, Tag, Push Minor Tag | ||
uses: docker/build-push-action@v3 | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ${{ env.IMAGE_REPOSITORY }}:${{ env.MINOR_TAG }} | ||
build-args: | | ||
REVISION_HASH=${{ env.GITHUB_SHA }} | ||
cache-from: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-minor | ||
cache-to: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-minor | ||
- | ||
name: Build, Tag, Push Patch Tag | ||
uses: docker/build-push-action@v3 | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ${{ env.IMAGE_REPOSITORY }}:${{ env.PATCH_TAG }} | ||
build-args: | | ||
REVISION_HASH=${{ env.GITHUB_SHA }} | ||
cache-from: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-patch | ||
cache-to: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-patch | ||
- | ||
name: Deploy Static Assets to GCS Bucket | ||
run: | | ||
|
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"sources": [ | ||
{ | ||
"name": "client", | ||
"directory": "src/core/client", | ||
"blockedImports": [ | ||
"coral-server/" | ||
], | ||
"extensions": [ ".ts", ".tsx" ] | ||
}, | ||
{ | ||
"name": "server", | ||
"directory": "src/core/server", | ||
"blockedImports": [ | ||
"coral-client/", | ||
"coral-stream/", | ||
"coral-framework/" | ||
], | ||
"extensions": [ ".ts" ] | ||
} | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,107 @@ | ||
/* eslint-disable no-console */ | ||
|
||
import fs from "fs"; | ||
import path from "path"; | ||
import readLine from "readline"; | ||
|
||
const CONFIG_FILE = "importBlocker.json"; | ||
|
||
interface Source { | ||
name: string; | ||
directory: string; | ||
blockedImports: string[]; | ||
extensions: string[]; | ||
} | ||
|
||
interface Config { | ||
sources: Source[]; | ||
} | ||
|
||
interface Error { | ||
path: string; | ||
lineNumber: number; | ||
line: string; | ||
} | ||
|
||
const loadConfig = (): Config => { | ||
const configRaw = fs.readFileSync(CONFIG_FILE).toString(); | ||
const config = JSON.parse(configRaw) as Config; | ||
|
||
return config; | ||
}; | ||
|
||
const errors: Error[] = []; | ||
|
||
const processFile = async ( | ||
source: Source, | ||
filePath: string, | ||
filters: string[] | ||
) => { | ||
const stream = fs.createReadStream(filePath); | ||
const reader = readLine.createInterface({ | ||
input: stream, | ||
crlfDelay: Infinity, | ||
}); | ||
|
||
let lineCounter = 0; | ||
for await (const line of reader) { | ||
for (const filter of filters) { | ||
if (line.includes(filter)) { | ||
errors.push({ | ||
path: filePath, | ||
lineNumber: lineCounter, | ||
line, | ||
}); | ||
} | ||
} | ||
|
||
lineCounter++; | ||
} | ||
}; | ||
|
||
const processDir = async (source: Source, dir: string, filters: string[]) => { | ||
const items = fs.readdirSync(dir); | ||
|
||
for (const item of items) { | ||
const fullPath = path.join(dir, item); | ||
const stats = fs.lstatSync(fullPath); | ||
|
||
if (stats.isDirectory()) { | ||
await processDir(source, fullPath, filters); | ||
} else if (stats.isFile()) { | ||
const ext = path.extname(item); | ||
|
||
if (source.extensions.includes(ext)) { | ||
await processFile(source, fullPath, filters); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const run = async () => { | ||
const config = loadConfig(); | ||
|
||
for (const source of config.sources) { | ||
const filters = source.blockedImports.map( | ||
(blockedImport) => `from "${blockedImport}` | ||
); | ||
|
||
await processDir(source, source.directory, filters); | ||
} | ||
|
||
if (errors.length > 0) { | ||
console.error("Blocked imports linter found the following errors:"); | ||
|
||
for (const error of errors) { | ||
console.error( | ||
` Blocked import found in '${error.path}' on line ${error.lineNumber}: ${error.line}` | ||
); | ||
} | ||
|
||
process.exit(1); | ||
} else { | ||
console.log("Blocked imports linter found 0 errors."); | ||
} | ||
}; | ||
|
||
run().finally(() => {}); |
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
Oops, something went wrong.