From 6aeac5252e1c7fc6c03a21cdbc34a2321c478acf Mon Sep 17 00:00:00 2001 From: Ryan Belev Date: Mon, 15 May 2023 13:02:07 -0700 Subject: [PATCH 1/5] fix(elastic): set test_command (#50) --- .github/workflows/test-integration-elastic.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-integration-elastic.yml b/.github/workflows/test-integration-elastic.yml index f99378c..f9397d8 100644 --- a/.github/workflows/test-integration-elastic.yml +++ b/.github/workflows/test-integration-elastic.yml @@ -7,6 +7,11 @@ on: description: 'The GitHub/npm token' required: true inputs: + test_command: + description: 'The command to run the integration tests' + default: 'npm run test:ci' + required: false + type: string elastic_password: description: 'The Elastic password' default: 'changeme' From 7cc2e82d5785d10b378dfcab920a055a8c278c32 Mon Sep 17 00:00:00 2001 From: Michael Patterson Date: Wed, 24 May 2023 16:10:45 -0500 Subject: [PATCH 2/5] Update GHA to not run test suite twice (#52) --- .github/workflows/test-integration-postgres-redis-rabbit.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test-integration-postgres-redis-rabbit.yml b/.github/workflows/test-integration-postgres-redis-rabbit.yml index 3ee6785..7493105 100644 --- a/.github/workflows/test-integration-postgres-redis-rabbit.yml +++ b/.github/workflows/test-integration-postgres-redis-rabbit.yml @@ -130,8 +130,5 @@ jobs: env: ENVIRONMENT: test POSTGRES_HOST: ${{ inputs.postgres_host }} - - run: ${{ inputs.test_command }} - env: - ENVIRONMENT: test - name: Codecov Uploader uses: codecov/codecov-action@v3 From ba1ac6fa7d6ed3eb5c4467f58ff2442199f17059 Mon Sep 17 00:00:00 2001 From: Ryan Belev Date: Fri, 21 Jul 2023 00:52:11 -0700 Subject: [PATCH 3/5] feat: postgres-mongo-elastic (#56) --- ...est-integration-postgres-mongo-elastic.yml | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 .github/workflows/test-integration-postgres-mongo-elastic.yml diff --git a/.github/workflows/test-integration-postgres-mongo-elastic.yml b/.github/workflows/test-integration-postgres-mongo-elastic.yml new file mode 100644 index 0000000..08ebeff --- /dev/null +++ b/.github/workflows/test-integration-postgres-mongo-elastic.yml @@ -0,0 +1,174 @@ +name: Reusable workflow for running postgres, mongo, elastic integration tests + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + inputs: + setup_global_postgres: + description: 'Setup Postgres @openphone/database repo' + default: true + required: false + type: boolean + migration_command: + description: 'The command to run the Postgres migrations' + default: 'npm run db:up' + required: false + type: string + skip_migration: + description: 'Whether or not the migrations should be skipped. Useful for when you want to run specific migration tests' + default: false + required: false + type: boolean + test_command: + description: 'The command to run the integration tests' + default: 'npm run test:ci' + required: false + type: string + postgres_version: + description: 'The version of Postgres to use' + default: '13' + required: false + type: string + postgres_user: + description: 'The Postgres user' + default: 'openphone' + required: false + type: string + postgres_password: + description: 'The Postgres password' + default: 'docker' + required: false + type: string + postgres_host: + description: 'The Postgres host' + default: 'localhost' + required: false + type: string + postgres_database: + description: 'The Postgres database' + default: 'openphone' + required: false + type: string + mongo_version: + description: 'The version of Mongo to use' + default: '4.2' + required: false + type: string + mongo_username: + description: 'The Mongo username' + default: 'admin' + required: false + type: string + mongo_password: + description: 'The Mongo password' + default: 'docker' + required: false + type: string + mongo_db: + description: 'The Mongo db name' + default: 'openphone' + required: false + type: string + elastic_password: + description: 'The Elastic password' + default: 'changeme' + required: false + type: string + elastic_url: + description: 'The Elastic host url' + default: 'http://localhost:9200' + required: false + type: string + +jobs: + test-integration-postgres-mongo-elastic: + runs-on: ubuntu-latest + + services: + postgres-svc: + image: postgres:13 + env: + POSTGRES_USER: ${{ inputs.postgres_user }} + POSTGRES_PASSWORD: ${{ inputs.postgres_password }} + POSTGRES_DB: ${{ inputs.postgres_database }} + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:8.1.2 + env: + STACK_VERSION: 8.1.2 + ELASTIC_PASSWORD: ${{ inputs.elastic_password }} + discovery.type: single-node + xpack.security.enabled: false + ports: + - 9200:9200 + options: >- + --health-cmd "curl http://localhost:9200/_cluster/health" + --health-interval 10s + --health-timeout 5s + --health-retries 10 + + steps: + - name: Setup node 18 + uses: actions/setup-node@v3 + with: + node-version: '18' + registry-url: https://npm.pkg.github.com/ + scope: '@openphone' + - name: spool up mongo + uses: supercharge/mongodb-github-action@1.7.0 + with: + mongodb-version: ${{ inputs.mongo_version }} + mongodb-username: ${{ inputs.mongo_username }} + mongodb-password: ${{ inputs.mongo_password }} + mongodb-db: ${{ inputs.mongo_db }} + - uses: actions/checkout@v3 + - run: npm ci + env: + NODE_AUTH_TOKEN: ${{ secrets.token }} + # Setup of the global postgres database. + - name: actions/checkout@v3 @openphone/database + uses: actions/checkout@v3 + if: ${{ inputs.setup_global_postgres && !inputs.skip_migration }} + with: + repository: 'OpenPhone/database' + path: 'database' + token: ${{ secrets.token }} + - name: migrate global postgres database + run: | + npm ci + npm run up + if: ${{ inputs.setup_global_postgres && !inputs.skip_migration }} + working-directory: 'database' + env: + NODE_AUTH_TOKEN: ${{ secrets.token }} + ENVIRONMENT: localdev + POSTGRES_HOST: ${{ inputs.postgres_host }} + # Run migrations against the local postgres database. + - run: ${{ inputs.migration_command }} + if: ${{ !inputs.setup_global_postgres && !inputs.skip_migration }} + env: + ENVIRONMENT: test + POSTGRES_HOST: ${{ inputs.postgres_host }} + # Test all the things!!! + - run: ${{ inputs.test_command }} + env: + ENVIRONMENT: test + PG_HOST: ${{ inputs.postgres_host }} + PG_USERNAME: ${{ inputs.postgres_user }} + PG_DATABASE: ${{ inputs.postgres_database }} + PG_PASSWORD: ${{ inputs.postgres_password }} + ELASTIC_URL: ${{ inputs.elastic_url }} + ELASTIC_PASSWORD: ${{ inputs.elastic_password }} + # Upload the coverage report to codecov.io. + - name: Codecov Uploader + uses: codecov/codecov-action@v3 From 1ef6c14a4acb69d19af95597e2b6e6daf93b3865 Mon Sep 17 00:00:00 2001 From: Eric Haynes Date: Mon, 28 Aug 2023 17:50:41 -0400 Subject: [PATCH 4/5] Add eco to CODEOWNERS --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f101e27..4a31b3d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @thesmo @Wagan8r +* @thesmo @Wagan8r @ehaynes99 @jpshilton-op From 2e67a3467f942150306239f90acbfe34e1381ac7 Mon Sep 17 00:00:00 2001 From: jpshilton-op <115495150+jpshilton-op@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:09:44 -0400 Subject: [PATCH 5/5] chore(ECO-265): Make Commonly Used Actions and Workflows Reusable (#57) --- .github/actions/publish/action.yml | 18 +++++++++++ .github/actions/setup/action.yml | 32 +++++++++++++++++++ ...-and-publish-typescript-project-client.yml | 30 +++++++++++++++++ ...d-and-publish-typescript-project-types.yml | 30 +++++++++++++++++ .../build-and-publish-typescript-project.yml | 27 ++++++++++++++++ .../build-typescript-project-client.yml | 30 +++++++++++++++++ .../build-typescript-project-types.yml | 27 ++++++++++++++++ .../workflows/build-typescript-project.yml | 30 +++++++++++++++++ .github/workflows/getsha.yml | 20 ++++++++++++ .github/workflows/getver.yml | 21 ++++++++++++ 10 files changed, 265 insertions(+) create mode 100644 .github/actions/publish/action.yml create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/workflows/build-and-publish-typescript-project-client.yml create mode 100644 .github/workflows/build-and-publish-typescript-project-types.yml create mode 100644 .github/workflows/build-and-publish-typescript-project.yml create mode 100644 .github/workflows/build-typescript-project-client.yml create mode 100644 .github/workflows/build-typescript-project-types.yml create mode 100644 .github/workflows/build-typescript-project.yml create mode 100644 .github/workflows/getsha.yml create mode 100644 .github/workflows/getver.yml diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 0000000..e453bc5 --- /dev/null +++ b/.github/actions/publish/action.yml @@ -0,0 +1,18 @@ +name: Set Version And Publish + +inputs: + version: + required: true + token: + required: true + +runs: + using: "composite" + steps: + - name: Set Version + run: npm version "${{ inputs.version }}" --no-git-tag-version --no-commit-hooks + + - name: Publish + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ inputs.token }} diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..c7dab83 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,32 @@ +name: Setup Runtime and Dependencies + +inputs: + token: + required: true + +runs: + using: "composite" + steps: + - name: Setup node 18 + uses: actions/setup-node@v3 + with: + node-version: '18' + registry-url: https://npm.pkg.github.com/ + scope: '@openphone' + + - name: Checkout + uses: actions/checkout@v3 + + - name: Cache dependencies + id: cache + uses: actions/cache@v3 + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Run CI + if: steps.cache.outputs.cache-hit != 'true' + run: npm ci + shell: bash + env: + NODE_AUTH_TOKEN: ${{inputs.token}} diff --git a/.github/workflows/build-and-publish-typescript-project-client.yml b/.github/workflows/build-and-publish-typescript-project-client.yml new file mode 100644 index 0000000..1ed1853 --- /dev/null +++ b/.github/workflows/build-and-publish-typescript-project-client.yml @@ -0,0 +1,30 @@ +name: Build Client + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + getver: + uses: OpenPhone/gha/.github/workflows/getver.yml@v4 + + build-client: + name: Build and Publish Client + runs-on: ubuntu-22.04 + needs: getver + if: github.event_name == 'push' + defaults: + run: + working-directory: ./client + steps: + - name: Build + uses: OpenPhone/gha/.github/workflows/build-typescript-project-client.yml@v4 + + - name: Publish + uses: OpenPhone/gha/.github/actions/publish@v4 + with: + token: ${{ inputs.token }} + version: ${{ needs.getver.outputs.version }} diff --git a/.github/workflows/build-and-publish-typescript-project-types.yml b/.github/workflows/build-and-publish-typescript-project-types.yml new file mode 100644 index 0000000..49b1083 --- /dev/null +++ b/.github/workflows/build-and-publish-typescript-project-types.yml @@ -0,0 +1,30 @@ +name: Build Application + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + getver: + uses: OpenPhone/gha/.github/workflows/getver.yml@v4 + + build-types: + name: Build and Publish Types + runs-on: ubuntu-22.04 + needs: getver + if: github.event_name == 'push' + defaults: + run: + working-directory: ./types + steps: + - name: Build + uses: OpenPhone/gha/.github/workflows/build-typescript-project-types.yml@v4 + + - name: Publish + uses: OpenPhone/gha/.github/actions/publish@v4 + with: + token: ${{ inputs.token }} + version: ${{ needs.getver.outputs.version }} diff --git a/.github/workflows/build-and-publish-typescript-project.yml b/.github/workflows/build-and-publish-typescript-project.yml new file mode 100644 index 0000000..a69e86a --- /dev/null +++ b/.github/workflows/build-and-publish-typescript-project.yml @@ -0,0 +1,27 @@ +name: Build Application + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + getver: + uses: OpenPhone/gha/.github/workflows/getver.yml@v4 + + build: + name: Build and Publish Types + runs-on: ubuntu-22.04 + needs: getver + if: github.event_name == 'push' + steps: + - name: Build + uses: OpenPhone/gha/.github/workflows/build-typescript-project.yml@v4 + + - name: Publish + uses: OpenPhone/gha/.github/actions/publish@v4 + with: + token: ${{ inputs.token }} + version: ${{ needs.getver.outputs.version }} diff --git a/.github/workflows/build-typescript-project-client.yml b/.github/workflows/build-typescript-project-client.yml new file mode 100644 index 0000000..6af2bbc --- /dev/null +++ b/.github/workflows/build-typescript-project-client.yml @@ -0,0 +1,30 @@ +name: Build Client + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + build-client: + name: Build Client + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: ./client + steps: + - name: Setup + uses: OpenPhone/gha/.github/actions/setup@v4 + with: + token: ${{ secrets.token }} + + - name: Lint + run: npm run lint + + - name: Build + run: npm run build + + - name: Test + run: npm node . diff --git a/.github/workflows/build-typescript-project-types.yml b/.github/workflows/build-typescript-project-types.yml new file mode 100644 index 0000000..0d39ace --- /dev/null +++ b/.github/workflows/build-typescript-project-types.yml @@ -0,0 +1,27 @@ +name: Build Types + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + build-types: + name: Build Types + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: ./types + steps: + - name: Setup + uses: OpenPhone/gha/.github/actions/setup@v4 + with: + token: ${{ secrets.token }} + + - name: Build + run: npm run build + + - name: Test + run: npm node . diff --git a/.github/workflows/build-typescript-project.yml b/.github/workflows/build-typescript-project.yml new file mode 100644 index 0000000..0a7d5ad --- /dev/null +++ b/.github/workflows/build-typescript-project.yml @@ -0,0 +1,30 @@ +name: Build Application + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + build: + name: Build + runs-on: ubuntu-22.04 + steps: + - name: Setup + uses: OpenPhone/gha/.github/actions/setup@v4 + with: + token: ${{ secrets.token }} + + - name: Lint + run: npm run lint + + - name: Typecheck + run: npm run typecheck + + - name: Build + run: npm run build + + - name: Run + run: node . diff --git a/.github/workflows/getsha.yml b/.github/workflows/getsha.yml new file mode 100644 index 0000000..7fe4986 --- /dev/null +++ b/.github/workflows/getsha.yml @@ -0,0 +1,20 @@ +name: Get GitHub SHA + +on: + workflow_call: + outputs: + sha: + value: ${{ jobs.getsha.outputs.sha }} + +jobs: + getsha: + name: Get SHA + runs-on: ubuntu-22.04 + + outputs: + sha: ${{ steps.getsha.outputs.sha }} + + steps: + - id: getsha + shell: bash + run: echo "sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/getver.yml b/.github/workflows/getver.yml new file mode 100644 index 0000000..ea2210f --- /dev/null +++ b/.github/workflows/getver.yml @@ -0,0 +1,21 @@ +name: Get Version from Tag + +on: + workflow_call: + outputs: + version: + value: ${{ jobs.getver.outputs.version }} + +jobs: + getver: + name: Get Version + runs-on: ubuntu-22.04 + + outputs: + version: ${{ steps.vertag.outputs.version }} + + steps: + - id: vertag + shell: bash + if: startsWith(github.ref, 'refs/tags/v') + run: echo "version=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT