From 120ae1b18db0e7ded6f7644ed89a234c5778bc70 Mon Sep 17 00:00:00 2001 From: Adam McManus Date: Tue, 7 Mar 2023 13:05:07 -0600 Subject: [PATCH] Adam/custom circleci images (#3085) * initial circleci changes, this will fail * update tests to fix date formatting * for now, track node setup with vxsuite-build-system * switch to votingworks repo in docker hub with versioned images * circleci image version bump * remove package install dependency --- .circleci/config.yml | 23 +++--- ansible/playbooks/setup-node.yaml | 72 +++++++++++-------- .../src/__snapshots__/app.test.tsx.snap | 4 +- libs/ui/src/tally_report_metadata.test.tsx | 2 +- libs/utils/src/format.test.ts | 2 +- 5 files changed, 58 insertions(+), 45 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 544f6d9fc..a2d7827a3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,10 +6,16 @@ orbs: executors: nodejs-browsers: docker: - - image: cimg/python:3.9.12-browsers + - image: votingworks/cimg-debian11-browsers:2.0.0 + auth: + username: $VX_DOCKER_USERNAME + password: $VX_DOCKER_PASSWORD nodejs: docker: - - image: cimg/node:16.14.2 + - image: votingworks/cimg-debian11:2.0.0 + auth: + username: $VX_DOCKER_USERNAME + password: $VX_DOCKER_PASSWORD jobs: test-codemods: @@ -810,8 +816,8 @@ jobs: path: libs/utils/reports/ test-services-converter-ms-sems: - docker: - - image: circleci/python:3.9.2 + executor: nodejs + resource_class: medium steps: - checkout - run: @@ -830,8 +836,8 @@ jobs: # make -C services/converter-ms-sems typecheck test-services-smartcards: - docker: - - image: circleci/python:3.9.2 + executor: nodejs + resource_class: medium steps: - checkout - run: @@ -909,9 +915,6 @@ commands: checkout-and-install: description: Get the code and install dependencies. steps: - - run: - name: Enable Corepack - command: sudo corepack enable - checkout # Edit this comment somehow in order to invalidate the CircleCI cache. # Since the contents of this file affect the cache key, editing only a @@ -923,8 +926,6 @@ commands: - run: name: Setup Dependencies command: | - sudo apt update -y - sudo apt install libx11-dev libpng-dev libjpeg-dev libpcsclite1 libpcsclite-dev pnpm install --frozen-lockfile - save_cache: key: diff --git a/ansible/playbooks/setup-node.yaml b/ansible/playbooks/setup-node.yaml index 5b9fd982d..ad1dcf9cd 100644 --- a/ansible/playbooks/setup-node.yaml +++ b/ansible/playbooks/setup-node.yaml @@ -1,42 +1,54 @@ --- -- name: Install Node and other dependencies +- name: Install/Upgrade Node and other dependencies hosts: 127.0.0.1 connection: local become: true vars: - node_version: "16.19.1*" - node_repo_version: "16.x" + node_version: "16.19.1" npm_packages: - - yarn + - yarn@1.22.15 - pnpm@7.24.3 tasks: - - name: "Add nodejs apt key" - ansible.builtin.apt_key: - url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key - state: present - - - name: "Add nodejs {{ node_version }} apt repo" - ansible.builtin.apt_repository: - repo: deb https://deb.nodesource.com/node_{{ node_repo_version }} bullseye main - update_cache: yes - - - name: "Add nodejs {{ node_version }} src apt repo" - ansible.builtin.apt_repository: - repo: deb-src https://deb.nodesource.com/node_{{ node_repo_version }} bullseye main - update_cache: yes - - - name: "Install Node {{ node_version }}" - ansible.builtin.apt: - update_cache: yes - name: "nodejs={{ node_version }}" - state: present - - - name: "Install base npm packages" - community.general.npm: - global: yes - name: "{{ item }}" - loop: "{{ npm_packages }}" + - name: Determine system architecture + set_fact: + architecture: "{{ 'arm64' if (ansible_architecture == 'aarch64' or ansible_architecture == 'arm64') else 'x64' if (ansible_architecture == 'x86_64') else 'unsupported' }}" + + - name: Remove pre-packaged Node (if present) + ansible.builtin.package: + name: nodejs + state: absent + + - name: Install/Upgrade Node on supported architectures + block: + + - name: Set Node release URL + set_fact: + release_url: "https://nodejs.org/dist/v{{ node_version }}/node-v{{ node_version }}-linux-{{ architecture }}.tar.gz" + + - name: Download and extract Node + ansible.builtin.unarchive: + src: "{{ release_url }}" + dest: /usr/local + remote_src: yes + extra_opts: + - --strip-components=1 + + - name: See if corepack is present + command: "which corepack" + register: corepack_installed + ignore_errors: yes + + - name: Disable corepack if installed + command: corepack disable + when: corepack_installed.rc == 0 + + - name: Install package managers + command: "npm install -g {{ item }}" + loop: "{{ npm_packages }}" + + when: architecture != 'unsupported' + diff --git a/apps/admin/frontend/src/__snapshots__/app.test.tsx.snap b/apps/admin/frontend/src/__snapshots__/app.test.tsx.snap index a75f6f6bb..29ac7e882 100644 --- a/apps/admin/frontend/src/__snapshots__/app.test.tsx.snap +++ b/apps/admin/frontend/src/__snapshots__/app.test.tsx.snap @@ -349,7 +349,7 @@ exports[`L&A (logic and accuracy) flow 1`] = ` class="c4" > This report was created on - Tuesday, November 3, 2020, 10:22:00 PM UTC + Tuesday, November 3, 2020 at 10:22:00 PM UTC .

@@ -3716,7 +3716,7 @@ exports[`tabulating CVRs 1`] = ` class="c4" > This report was created on - Tuesday, November 3, 2020, 10:22:00 PM UTC + Tuesday, November 3, 2020 at 10:22:00 PM UTC .

diff --git a/libs/ui/src/tally_report_metadata.test.tsx b/libs/ui/src/tally_report_metadata.test.tsx index f465929ce..89bd75b24 100644 --- a/libs/ui/src/tally_report_metadata.test.tsx +++ b/libs/ui/src/tally_report_metadata.test.tsx @@ -25,6 +25,6 @@ test('Renders report metadata', () => { getByText(/Choctaw County/); getByText(/State of Mississippi/); getByText( - /This report was created on Tuesday, November 3, 2020, 10:22:00 PM UTC/ + /This report was created on Tuesday, November 3, 2020 at 10:22:00 PM UTC/ ); }); diff --git a/libs/utils/src/format.test.ts b/libs/utils/src/format.test.ts index 4766e68a3..d965b3443 100644 --- a/libs/utils/src/format.test.ts +++ b/libs/utils/src/format.test.ts @@ -19,7 +19,7 @@ test('formats counts properly', () => { test('formats locale long date and time properly', () => { expect( format.localeLongDateAndTime(new Date(2020, 3, 14, 1, 15, 9, 26)) - ).toEqual('Tuesday, April 14, 2020, 1:15:09 AM UTC'); + ).toEqual('Tuesday, April 14, 2020 at 1:15:09 AM UTC'); }); test('formats locale weekday and date properly', () => {