Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Commit

Permalink
Move to github actions (#67)
Browse files Browse the repository at this point in the history
* Move to github actions
  • Loading branch information
matteofigus authored Feb 19, 2021
1 parent 9f05e8f commit 09ca4b1
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 91 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---

name: Publish Version
on:
release:
types: [created, edited]
jobs:
publish:
name: Publish Version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Fetch Tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-session-token: ${{ secrets.AWS_SESSION_TOKEN }}
aws-region: ${{ secrets.REGION }}
- name: Set version
id: version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
# Cache
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Setup
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set up Nodejs 12
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install node dependencies
run: npm i
- name: Install python dependencies
run: pip3 install -r requirements.txt
# Package and Upload Archive
- name: Build Release
run: npm run build
- name: Upload artefact
run: npm run deploy
env:
CFN_BUCKET: ${{ secrets.CFN_BUCKET }}
57 changes: 57 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---

name: Release Version
on:
push:
branches:
- master
jobs:
release:
name: Release Version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
# Cache
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Setup
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set up Nodejs 12
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
run: npm i
- name: Install python dependencies
run: pip3 install -r requirements.txt
- name: Build Template
run: npm run build
# Release if required
- name: Set version
id: version
run: |
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
echo "THIS_VERSION=$(npm run echo-version --silent | sed s/^v//)" >> $GITHUB_ENV
echo "THIS_VERSION_COMPARABLE=$(version $(npm run echo-version --silent | sed s/^v//))" >> $GITHUB_ENV
echo "LATEST_VERSION_COMPARABLE=$(version $(git describe --tags $(git rev-list --tags --max-count=1) | sed s/^v// 2> /dev/null || echo '0'))" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@latest
if: env.THIS_VERSION_COMPARABLE > env.LATEST_VERSION_COMPARABLE
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: v${{ env.THIS_VERSION }}
release_name: Release v${{ env.THIS_VERSION }}
body: |
See the commits for a list of features included in this release
draft: false
prerelease: false
49 changes: 49 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---

name: Unit Tests
on:
push:
branches:
- master
pull_request:
types:
- opened
- edited
- synchronize
jobs:
unit_tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Cache
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Setup
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set up Nodejs 12
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
run: npm i
- name: Install python dependencies
run: pip3 install -r requirements.txt
- name: Build Template
run: npm run build
# Run Tests
- name: Unit tests
run: npm test
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

18 changes: 0 additions & 18 deletions ci/params.json

This file was deleted.

20 changes: 0 additions & 20 deletions ci/taskcat.yml

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"cfn-lambdas-dist-setup": "if [ ! -d './backend/functions/setup/' ]; then mkdir -p backend/functions/setup/; fi",
"cfn-test": "yamllint -d '{extends: default, rules: {line-length: disable}}' src/cfn/template.yaml && cfn-lint src/cfn/template.yaml",
"cfn-test-local": "npm run lambda-build && npm run cfn-build && aws cloudformation package --template-file templates/template.yaml --output-template-file templates/packaged.yaml --s3-bucket $TEST_BUCKET && aws cloudformation deploy --template-file templates/packaged.yaml --stack-name amazon-transcribe-news-media-analysis --capabilities CAPABILITY_IAM",
"deploy": "npm run zip && aws --profile publisher s3 cp ./`npm run echo-version --silent`.zip s3://$CFN_BUCKET/$npm_package_name/`npm run echo-version --silent`/$npm_package_name.zip",
"deploy": "npm run zip && aws s3 cp ./`npm run echo-version --silent`.zip s3://$CFN_BUCKET/$npm_package_name/`npm run echo-version --silent`/$npm_package_name.zip",
"echo-version": "echo v`node -e \"console.log(require('node-yaml').readSync('templates/template.yaml').Globals.Function.Environment.Variables.VERSION)\"`",
"lambda-build": "npm run lambda-build-layers && npm run lambda-build-orchestrator && npm run lambda-build-setup",
"lambda-build-layers": "cd src/backend/functions/layers && npm run build",
Expand All @@ -28,7 +28,6 @@
"lambda-clean": "rm -rf src/backend/functions/layers/aws_sdk/nodejs && rm -rf src/backend/functions/layers/fp/nodejs",
"orch-test": "cd src/backend/functions/orchestrator && npm t",
"postinstall": "cd src/frontend && npm i && cd ../backend/functions/setup && npm i && cd ../orchestrator && npm i",
"pre-deploy-test": "taskcat -c ci/taskcat.yml --verbose --exclude src --exclude docs --exclude taskcat_outputs",
"start": "cd src/frontend && npm start",
"tag": "git tag `npm run echo-version --silent`",
"test": "npm run cfn-test && npm run webui-test && npm run orch-test",
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ aws-sam-translator==1.13.0
awscli==1.16.205
cfn_flip==1.1.0
cfn_lint==0.22.4
taskcat==0.8.40
yamllint==1.17.0
2 changes: 1 addition & 1 deletion src/cfn/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Globals:
Runtime: nodejs10.x
Environment:
Variables:
VERSION: '1.5'
VERSION: '1.6'

Parameters:

Expand Down

0 comments on commit 09ca4b1

Please sign in to comment.