Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Node.js to v18 - abandoned #479

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions .github/workflows/build.yml

This file was deleted.

84 changes: 84 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Checks

on:
workflow_call:
inputs:
node-version:
default: "18"
required: false
type: string

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Node.JS
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: npm

- name: Install dependencies
run: npm ci

- name: Build packages
run: npm run build

# - name: Build node-canvas libraries
# run: docker build -t canvas-libs .

# - name: Inject libraries
# run: |
# id=$(docker create canvas-libs)
# docker cp $id:/root/dist ./packages/create-map
# docker cp $id:/root/dist ./packages/add-token
# docker cp $id:/root/dist ./packages/move-delete-token
# docker rm -v $id

- name: Upload packages
uses: actions/upload-artifact@v3
with:
name: packages
path: packages/**/dist/
lint:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- name: Set up Node.JS
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: npm

- name: Install Node dependencies
run: npm ci

- name: Lint packages
run: npm run lint
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- name: Set up Node.JS
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: npm

- name: Install Node dependencies
run: npm ci

- name: Download packages
uses: actions/download-artifact@v3
with:
name: packages
path: packages

- name: Test packages
run: npm t --workspaces --if-present
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
required: false
type: string
node-version:
default: "16"
default: "18"
required: false
type: string
secrets:
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@ on:
- "!packages/terraform/user/**"

jobs:
build:
uses: ./.github/workflows/build.yml
lint:
needs: build
uses: ./.github/workflows/lint.yml
unit:
needs: build
uses: ./.github/workflows/unit-test.yml
checks:
uses: ./.github/workflows/checks.yml
integration:
needs: build
needs: checks
uses: ./.github/workflows/integration-test.yml
secrets:
discord_token: ${{ secrets.BOT_TOKEN }}
deploy:
needs: [lint, unit, integration]
needs: integration
uses: ./.github/workflows/deploy.yml
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
51 changes: 11 additions & 40 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ on:
workflow_call:
inputs:
node-version:
default: "16"
default: "18"
required: false
type: string
secrets:
discord_token:
private-key:
required: true
type: string
map-bucket:
required: true
type: string

jobs:
test:
runs-on: ubuntu-latest
env:
# These aren't actually secret, they're just for testing purposes.
PUBLIC_KEY: a58293d7fa04d53ab90108be275a87fe890eece595962273a93e1f87d398df74
CYPRESS_PRIVATE_KEY: 814d1a8737ba28a2ae72e39cac46468002525a64e4f002d7b52dd06efb9dc4b8a58293d7fa04d53ab90108be275a87fe890eece595962273a93e1f87d398df74
CYPRESS_MAP_BUCKET: carto-bot-maps
PRIVATE_KEY: ${{ inputs.private-key }}
MAP_BUCKET: ${{ inputs.map-bucket }}
steps:
- uses: actions/checkout@v3

Expand All @@ -39,39 +41,8 @@ jobs:
name: packages
path: packages

- name: Start Localstack
working-directory: packages/integration
run: docker-compose up -d

- name: Build test environment
working-directory: packages/terraform/localstack
run: |
terraform init
terraform apply \
-var="discord_public_key=${{ env.PUBLIC_KEY }}" \
-var="discord_token=${{ secrets.discord_token }}" \
-var="discord_base_url=http://172.17.0.1:3000" \
-auto-approve
- name: Setup tests
run: npm run setup --workspace=@carto/integration

- name: Run tests
uses: cypress-io/github-action@v4
with:
build: npm run setup -w @carto/integration
start: npm start -w @carto/mock-discord
project: packages/integration

- name: Upload screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-snapshots
path: packages/integration/cypress/screenshots

- name: Print docker-compose logs
if: failure()
working-directory: packages/integration
run: docker-compose logs

- name: Stop Localstack
working-directory: packages/integration
run: docker-compose down
run: npm run integration:test --workspace=@carto/integration
27 changes: 0 additions & 27 deletions .github/workflows/lint.yml

This file was deleted.

27 changes: 16 additions & 11 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ name: pr-checks
on: pull_request

jobs:
build:
uses: ./.github/workflows/build.yml
lint:
needs: build
uses: ./.github/workflows/lint.yml
unit:
needs: build
uses: ./.github/workflows/unit-test.yml
integration:
needs: build
uses: ./.github/workflows/integration-test.yml
checks:
uses: ./.github/workflows/checks.yml
deploy:
needs: checks
uses: ./.github/workflows/pr-environment.yml
with:
public-key: a58293d7fa04d53ab90108be275a87fe890eece595962273a93e1f87d398df74
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
discord_token: ${{ secrets.BOT_TOKEN }}
integration:
needs: deploy
uses: ./.github/workflows/integration-test.yml
with:
# Not actually private, just for testing purposes
private-key: 814d1a8737ba28a2ae72e39cac46468002525a64e4f002d7b52dd06efb9dc4b8a58293d7fa04d53ab90108be275a87fe890eece595962273a93e1f87d398df74
map-bucket: carto-bot-pr-${{ github.event.pull_request.number }}-maps
58 changes: 58 additions & 0 deletions .github/workflows/pr-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy PR Environment

on:
workflow_call:
inputs:
node-version:
default: "18"
required: false
type: string
public-key:
required: true
type: string
secrets:
aws_access_key_id:
required: true
aws_secret_access_key:
required: true
discord_token:
required: true

jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
steps:
- uses: actions/checkout@v3

- uses: hashicorp/setup-terraform@v2

- name: Set up Node.JS
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: npm

- name: Install Node dependencies
run: npm ci

- name: Download packages
uses: actions/download-artifact@v3
with:
name: packages
path: packages

- name: Apply terraform
working-directory: packages/terraform/development
run: |
terraform init \
-backend-config="bucket=carto-bot-tf-state" \
-backend-config="key=pr-${{ github.event.pull_request.number }}.tfstate" \
-backend-config="region=eu-central-1"
terraform apply \
-var="discord_public_key=${{ inputs.public-key }}" \
-var="discord_token=${{ secrets.discord_token }}" \
-var="app_name=carto-bot-pr-${{ github.event.pull_request.number }}" \
-auto-approve
30 changes: 30 additions & 0 deletions .github/workflows/pr-teardown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Teardown PR Environment

on:
pull_request:
types:
- closed

jobs:
destroy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v3

- uses: hashicorp/setup-terraform@v2

- name: Destroy PR environment
working-directory: packages/terraform/development
run: |
terraform init \
-backend-config="bucket=carto-bot-tf-state" \
-backend-config="key=pr-${{ github.event.pull_request.number }}.tfstate" \
-backend-config="region=eu-central-1"
terraform destroy \
-var="discord_public_key=na" \
-var="discord_token=na" \
-var="app_name=carto-bot-pr-${{ github.event.pull_request.number }}" \
-auto-approve
2 changes: 1 addition & 1 deletion .github/workflows/register-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Node.JS
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install dependencies
run: npm ci
Expand Down
Loading
Loading