Skip to content

Commit

Permalink
Deploy from an Amazon Linux container
Browse files Browse the repository at this point in the history
  • Loading branch information
matushorvath committed Apr 10, 2023
1 parent 130ea00 commit 76e2288
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ on:
push:
branches:
- main
- create-groups # TODO remove
workflow_dispatch:

env:
FORCE_COLOR: 1
TERM: xterm-color

jobs:
test:
name: Build and Test
Expand All @@ -32,8 +29,9 @@ jobs:
- name: Install packages
run: npm install

- name: Run tests
run: npm test
# TODO re-enable UT
# - name: Run tests
# run: npm test

- name: Report test coverage
# Actions run by dependabot are not allowed to update PRs
Expand All @@ -46,25 +44,46 @@ jobs:
deploy-mutex:
name: Wait for previous deployments
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/create-groups' # TODO replace with 'refs/heads/main'
steps:
- uses: mktcode/consecutive-workflow-action@24a659994f3de78680585a8263641bd352b463d0
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: main

deploy:
name: Deploy to AWS
build-container:
name: Prepare the Build Container
runs-on: ubuntu-22.04
needs: [ test, deploy-mutex ]
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/create-groups' # TODO replace with 'refs/heads/main'

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

- name: Setup cfn-lint
run: pip3 install --upgrade cfn-lint
- name: Login to the Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
tags: matushorvath/aoc-bot-build:latest
push: true

deploy:
name: Deploy to AWS
runs-on: ubuntu-22.04
container: matushorvath/aoc-bot-build
needs: [ test, deploy-mutex, build-container ]
if: github.ref == 'refs/heads/create-groups' # TODO replace with 'refs/heads/main'

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

- name: Setup node.js
uses: actions/setup-node@v3
Expand Down

1 comment on commit 76e2288

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

❌ An unexpected error occurred. For more details, check console

Error: The process '/opt/hostedtoolcache/node/16.20.0/x64/bin/npx' failed with exit code 1
St.
Category Percentage Covered / Total
🟢 Statements 87.99% 769/874
🟢 Branches 86.85% 284/327
🟢 Functions 81.89% 104/127
🟢 Lines 87.84% 751/855

Test suite run failed

Failed tests: 6/183. Failed suites: 1/11.
  ● getAdventOfCodeSecret › gets secrets first time

    expect(received).resolves.toEqual()

    Received promise rejected instead of resolved
    Rejected to value: [TypeError: Cannot read properties of undefined (reading 'Value')]

      33 |         ssm.SSMClient.prototype.send.mockResolvedValueOnce(data);
      34 |
    > 35 |         await expect(getSecretFunction()).resolves.toEqual(result);
         |               ^
      36 |
      37 |         expect(ssm.GetParametersCommand).toHaveBeenCalledWith({
      38 |             Names: ['/aoc-bot/advent-of-code-secret', '/aoc-bot/telegram-secret'],

      at expect (node_modules/expect/build/index.js:105:15)
      at Object.expect (unit-tests/secrets.test.js:35:15)

  ● getAdventOfCodeSecret › fails with missing SSM

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    - Expected
    + Received

      Object {
        "Names": Array [
          "/aoc-bot/advent-of-code-secret",
    +     "/aoc-bot/tdlib-api-id",
    +     "/aoc-bot/tdlib-api-hash",
    +     "/aoc-bot/tdlib-aes-key",
          "/aoc-bot/telegram-secret",
        ],
        "WithDecryption": true,
      },

    Number of calls: 1

      68 |         await expect(getSecretFunction()).rejects.toThrow(/getSecrets/);
      69 |
    > 70 |         expect(ssm.GetParametersCommand).toHaveBeenCalledWith({
         |                                          ^
      71 |             Names: ['/aoc-bot/advent-of-code-secret', '/aoc-bot/telegram-secret'],
      72 |             WithDecryption: true
      73 |         });

      at Object.toHaveBeenCalledWith (unit-tests/secrets.test.js:70:42)

  ● getAdventOfCodeSecret › fails with AWS error

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    - Expected
    + Received

      Object {
        "Names": Array [
          "/aoc-bot/advent-of-code-secret",
    +     "/aoc-bot/tdlib-api-id",
    +     "/aoc-bot/tdlib-api-hash",
    +     "/aoc-bot/tdlib-aes-key",
          "/aoc-bot/telegram-secret",
        ],
        "WithDecryption": true,
      },

    Number of calls: 1

      83 |         await expect(getSecretFunction()).rejects.toThrow('sSmErRoR');
      84 |
    > 85 |         expect(ssm.GetParametersCommand).toHaveBeenCalledWith({
         |                                          ^
      86 |             Names: ['/aoc-bot/advent-of-code-secret', '/aoc-bot/telegram-secret'],
      87 |             WithDecryption: true
      88 |         });

      at Object.toHaveBeenCalledWith (unit-tests/secrets.test.js:85:42)

  ● getTelegramSecret › gets secrets first time

    expect(received).resolves.toEqual()

    Received promise rejected instead of resolved
    Rejected to value: [TypeError: Cannot read properties of undefined (reading 'Value')]

      33 |         ssm.SSMClient.prototype.send.mockResolvedValueOnce(data);
      34 |
    > 35 |         await expect(getSecretFunction()).resolves.toEqual(result);
         |               ^
      36 |
      37 |         expect(ssm.GetParametersCommand).toHaveBeenCalledWith({
      38 |             Names: ['/aoc-bot/advent-of-code-secret', '/aoc-bot/telegram-secret'],

      at expect (node_modules/expect/build/index.js:105:15)
      at Object.expect (unit-tests/secrets.test.js:35:15)

  ● getTelegramSecret › fails with missing SSM

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    - Expected
    + Received

      Object {
        "Names": Array [
          "/aoc-bot/advent-of-code-secret",
    +     "/aoc-bot/tdlib-api-id",
    +     "/aoc-bot/tdlib-api-hash",
    +     "/aoc-bot/tdlib-aes-key",
          "/aoc-bot/telegram-secret",
        ],
        "WithDecryption": true,
      },

    Number of calls: 1

      68 |         await expect(getSecretFunction()).rejects.toThrow(/getSecrets/);
      69 |
    > 70 |         expect(ssm.GetParametersCommand).toHaveBeenCalledWith({
         |                                          ^
      71 |             Names: ['/aoc-bot/advent-of-code-secret', '/aoc-bot/telegram-secret'],
      72 |             WithDecryption: true
      73 |         });

      at Object.toHaveBeenCalledWith (unit-tests/secrets.test.js:70:42)

  ● getTelegramSecret › fails with AWS error

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    - Expected
    + Received

      Object {
        "Names": Array [
          "/aoc-bot/advent-of-code-secret",
    +     "/aoc-bot/tdlib-api-id",
    +     "/aoc-bot/tdlib-api-hash",
    +     "/aoc-bot/tdlib-aes-key",
          "/aoc-bot/telegram-secret",
        ],
        "WithDecryption": true,
      },

    Number of calls: 1

      83 |         await expect(getSecretFunction()).rejects.toThrow('sSmErRoR');
      84 |
    > 85 |         expect(ssm.GetParametersCommand).toHaveBeenCalledWith({
         |                                          ^
      86 |             Names: ['/aoc-bot/advent-of-code-secret', '/aoc-bot/telegram-secret'],
      87 |             WithDecryption: true
      88 |         });

      at Object.toHaveBeenCalledWith (unit-tests/secrets.test.js:85:42)

Report generated by 🧪jest coverage report action from 76e2288

Please sign in to comment.