Skip to content

Commit

Permalink
Chore: Config Github Actions (#434)
Browse files Browse the repository at this point in the history
* Config Github Actions

* Update codeql config

* Update node version on build

* Remove CircleCI config

Co-authored-by: Douglas Gubert <[email protected]>
  • Loading branch information
rodrigok and d-gubert authored Aug 18, 2022
1 parent 515cfc2 commit 7a5aa9a
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 146 deletions.
146 changes: 0 additions & 146 deletions .circleci/config.yml

This file was deleted.

176 changes: 176 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Build and Test

on:
release:
types: [published]
pull_request:

jobs:
prepare:
runs-on: ubuntu-latest

steps:
- name: Github Info
run: |
echo "GITHUB_ACTION: $GITHUB_ACTION"
echo "GITHUB_ACTOR: $GITHUB_ACTOR"
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF"
echo "GITHUB_BASE_REF: $GITHUB_BASE_REF"
echo "github.event_name: ${{ github.event_name }}"
cat $GITHUB_EVENT_PATH
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: "14.19.3"

- uses: actions/checkout@v2

- name: Versions
run: |
npm --versions
node -v
git version
- name: check package-lock
run: |
npx package-lock-check
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v2
with:
path: ./node_modules
key: ${{ runner.OS }}-node_modules-4-${{ hashFiles('./package-lock.json', '.github/workflows/build_and_test.yml') }}

- name: npm install
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm install

- name: Prepare workspace
run: |
tar czf /tmp/workspace.tar.gz .
- uses: actions/upload-artifact@v2
with:
name: workspace
path: /tmp/workspace.tar.gz

lint:
runs-on: ubuntu-latest
needs: prepare

steps:
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: "14.19.3"

- uses: actions/download-artifact@v2
with:
name: workspace
path: /tmp

- name: Decompress workspace
run: |
tar xzf /tmp/workspace.tar.gz .
- name: Lint TypeScript Code
run: npm run lint

test:
runs-on: ubuntu-latest
needs: prepare

steps:
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: "14.19.3"

- uses: actions/download-artifact@v2
with:
name: workspace
path: /tmp

- name: Decompress workspace
run: |
tar xzf /tmp/workspace.tar.gz .
- name: Test TypeScript Code
run: npm run unit-tests

build:
runs-on: ubuntu-latest
needs:
- lint
- test

steps:
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: "14.19.3"

- uses: actions/download-artifact@v2
with:
name: workspace
path: /tmp

- name: Decompress workspace
run: |
tar xzf /tmp/workspace.tar.gz .
- name: Compile TypeScript into JavaScript
run: npm run compile

- name: Prepare workspace
run: |
tar czf /tmp/workspace.tar.gz .
- uses: actions/upload-artifact@v2
with:
name: workspace
path: /tmp/workspace.tar.gz

publish:
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event_name == 'refs/heads/alpha' || github.ref == 'refs/heads/beta'
needs: build

steps:
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: "14.19.3"

- uses: actions/download-artifact@v2
with:
name: workspace
path: /tmp

- name: Decompress workspace
run: |
tar xzf /tmp/workspace.tar.gz .
- name: Authenticate with registry
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc

- name: Publish package
run: |
if [[ '${{ github.event_name }}' = 'release' ]]; then
npm publish --tag latest
else
# Add build number to the end of the version
npm version --no-git-tag-version "$(node -p "require('./package.json').version").${{ github.event.number }}"
GIT_BRANCH="${GITHUB_REF#*heads/}"
if [[ $GIT_BRANCH == 'alpha' ]]; then
npm run go-publish-alpha
else
npm run go-publish-beta
fi;
fi;
61 changes: 61 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: "Code scanning - action"

on:
push:
branches: [master, alpha]
pull_request:
branches: [master, alpha]
# schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
# - cron: '30 1 * * 0'

jobs:
CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest

permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
# actions: read
# contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

0 comments on commit 7a5aa9a

Please sign in to comment.