diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..8cd1e2d --- /dev/null +++ b/.github/workflows/publish.yaml @@ -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 }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4f0842d --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml new file mode 100644 index 0000000..18e28c9 --- /dev/null +++ b/.github/workflows/unit-tests.yaml @@ -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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 26cf69d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: node_js - -node_js: - - "10" - -# Install -before_script: - - pyenv global 3.7 - - python --version - - pip3 install -r requirements.txt --user - -# Build and Test. Fails if package.json version hasn't been incremented on a PR -script: - - npm run build - - npm t - - if [ $TRAVIS_PULL_REQUEST == true ] && [ $TRAVIS_BRANCH != "master" ]; then - npm run tag; - fi - -# Tag and Publish -before_deploy: - # - npm run pre-deploy-test - - mkdir -p ~/.aws - - cat >> ~/.aws/config <<<"[profile publisher]"$'\n'"credential_source=Environment"$'\n'"role_arn=${ROLE_ARN}"$'\n'"duration_seconds=900" - - export VERSION=${TRAVIS_TAG:-$(npm run echo-version --silent)} - - if [ -z "$TRAVIS_TAG" ]; then npm run tag; fi - - npm run zip - -deploy: - - provider: releases - api_key: - secure: 4b8eauaKcifpCUs1Usdb6aDuWCkyS4eJj0/OwhNBbBhBHIIDaFznaIDotqNasVnszZysiTF29eFiNCmFEV0R/Lh6iw5BsEqxa101hamIcmSUThOiOf4hjZFZ2qkmbeW+kzWlsGJ4KX/QVlff+ngeSGntM0gB5Ty1uepZ0J+Qla38NL1CFJkZ8BZkAKiwWDiiHkugHvH6dEROpI3zdk2YqG112c1Gm8GUQ20TYTudPfkexDNUMXuVa7VK7NNAmm259Jnx9Ip6PwhoD16uFXS6xKwGMFetwnU6U/1ujpPow40qpCBb67wn+5alWiOQFH1ADJCL6ORuIqWDvp5Fu2ImqFL8DzCWd+BXZAweoIDUBgOn82iNRXLttIcJsPpHIsTrsPB3F8fDkf1z2rBjhwyOgp/9iDiZWnn/vHYK3Svdqh8CRShDHGBxRxeixft+fs70v/+nLNnmZDPIYM7M0dKvE3DWl8kkaICPjUkzKNzq/Mkfl/6BxGVWexVNMkDs5ZSSrm5pwLd/NRf3VsLDEmzdG2/3eR69Co2YkLSPZkUN15Bt3oA+F6SdQP1oufh9NgK34wBiydNhQ9C7xerNswC3sgdrNydH3h6nV/Ksn2af/FcSxy8NF1FgDNlLn8gdCfeMd+DUa4FBnH8vPti2b3Fcht3GpQaW60vBOvj43mdBEcc= - file: $VERSION.zip - skip_cleanup: true - on: - branch: master - condition: type != pull_request - - provider: script - skip_cleanup: true - script: npm run deploy >/dev/null 2>&1 - on: - tags: true - -notifications: - email: false - -cache: - directories: - - $HOME/.m2 diff --git a/ci/params.json b/ci/params.json deleted file mode 100644 index e2d5213..0000000 --- a/ci/params.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "ParameterKey": "MaxTasksCapacity", - "ParameterValue": 10 - }, - { - "ParameterKey": "PrivateSubnetIpBlocks", - "ParameterValue": "10.0.0.0/22, 10.0.4.0/22, 10.0.8.0/22" - }, - { - "ParameterKey": "PublicSubnetIpBlocks", - "ParameterValue": "10.0.12.0/22, 10.0.16.0/22, 10.0.20.0/22" - }, - { - "ParameterKey": "VpcIpBlock", - "ParameterValue": "10.0.0.0/16" - } -] diff --git a/ci/taskcat.yml b/ci/taskcat.yml deleted file mode 100644 index 7aa9ca5..0000000 --- a/ci/taskcat.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -global: - owner: mfigus@amazon.com - qsname: amazon-transcribe-news-media-analysis - regions: - - ap-northeast-2 - - ap-south-1 - - ap-southeast-1 - - ap-southeast-2 - - ca-central-1 - - eu-central-1 - - eu-west-1 - - eu-west-2 - - us-east-1 - - us-east-2 - - us-west-2 -tests: - deploy: - parameter_input: params.json - template_file: template.yaml diff --git a/package.json b/package.json index 97405f6..ee1bf5d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/requirements.txt b/requirements.txt index ca4ec94..81842b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/src/cfn/template.yaml b/src/cfn/template.yaml index 6ebb60c..2c7ba7b 100644 --- a/src/cfn/template.yaml +++ b/src/cfn/template.yaml @@ -13,7 +13,7 @@ Globals: Runtime: nodejs10.x Environment: Variables: - VERSION: '1.5' + VERSION: '1.6' Parameters: