Skip to content

Commit

Permalink
Adam/custom circleci images (#3085)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
amcmanus authored Mar 7, 2023
1 parent cd9f2b0 commit 120ae1b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 45 deletions.
23 changes: 12 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
72 changes: 42 additions & 30 deletions ansible/playbooks/setup-node.yaml
Original file line number Diff line number Diff line change
@@ -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
- [email protected]

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'


4 changes: 2 additions & 2 deletions apps/admin/frontend/src/__snapshots__/app.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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
.
</span>
</p>
Expand Down Expand Up @@ -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
.
</span>
</p>
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/src/tally_report_metadata.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/
);
});
2 changes: 1 addition & 1 deletion libs/utils/src/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 120ae1b

Please sign in to comment.