From d813baa8878d1cc6efbe511b6bbb7a0609bc2fe7 Mon Sep 17 00:00:00 2001 From: "Eric O. Korman" Date: Mon, 18 Mar 2024 09:52:59 -0500 Subject: [PATCH] testing npm publish --- .github/workflows/api-docker.yml | 81 ---------- .github/workflows/build-and-publish.yml | 12 +- .github/workflows/check-pre-commit.yml | 18 --- .github/workflows/pg-docker.yml | 46 ------ .github/workflows/publish-docs.yml | 30 ---- .github/workflows/stress-test.yml | 81 ---------- .github/workflows/tests-and-coverage.yml | 184 ----------------------- 7 files changed, 5 insertions(+), 447 deletions(-) delete mode 100644 .github/workflows/api-docker.yml delete mode 100644 .github/workflows/check-pre-commit.yml delete mode 100644 .github/workflows/pg-docker.yml delete mode 100644 .github/workflows/publish-docs.yml delete mode 100644 .github/workflows/stress-test.yml delete mode 100644 .github/workflows/tests-and-coverage.yml diff --git a/.github/workflows/api-docker.yml b/.github/workflows/api-docker.yml deleted file mode 100644 index 9b34ea2fb..000000000 --- a/.github/workflows/api-docker.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Builds and publishes a docker image for the back end service - -on: - push: - paths: - - api/** - - migrations/** - - .github/workflows/docker.yml - branches: [main] - tags: - - "v*" - -permissions: - id-token: write - contents: read - packages: write - -jobs: - build-and-publish-docker-migrations: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./migrations - env: - IMAGE_NAME: ghcr.io/striveworks/valor/migrations - IMAGE_NAME_WITH_COMMIT_HASH: ${IMAGE_NAME}:${{ github.sha }} - steps: - - uses: actions/checkout@v3 - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: build - run: | - docker build . -t ${IMAGE_NAME} - - name: push - run: | - docker push ${IMAGE_NAME} - IMAGE_NAME_WITH_COMMIT_HASH=${IMAGE_NAME}:${{ github.sha }} - docker tag ${IMAGE_NAME} ${IMAGE_NAME_WITH_COMMIT_HASH} - docker push ${IMAGE_NAME_WITH_COMMIT_HASH} - - name: push git tag - if: startsWith(github.ref, 'refs/tags/') - run: | - TAG=$(git describe --tags --abbrev=0) - docker tag ${IMAGE_NAME} ${IMAGE_NAME}:${TAG} - docker push ${IMAGE_NAME}:${TAG} - - build-and-publish-docker-service: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./api - env: - IMAGE_NAME: ghcr.io/striveworks/valor/valor-service - IMAGE_NAME_WITH_COMMIT_HASH: ${IMAGE_NAME}:${{ github.sha }} - steps: - - uses: actions/checkout@v3 - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: build - run: | - pip3 install setuptools_scm - docker build --build-arg VERSION=$(python -m setuptools_scm) . -t ${IMAGE_NAME} - - name: push - run: | - docker push ${IMAGE_NAME} - IMAGE_NAME_WITH_COMMIT_HASH=${IMAGE_NAME}:${{ github.sha }} - docker tag ${IMAGE_NAME} ${IMAGE_NAME_WITH_COMMIT_HASH} - docker push ${IMAGE_NAME_WITH_COMMIT_HASH} - # if there's a git tag then add another tag to the image with the git tag and push it - - name: push git tag - if: startsWith(github.ref, 'refs/tags/') - run: | - TAG=$(git describe --tags --abbrev=0) - docker tag ${IMAGE_NAME} ${IMAGE_NAME}:${TAG} - docker push ${IMAGE_NAME}:${TAG} diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 594e56a17..b69f00189 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -1,4 +1,4 @@ -name: Build and publish python package +name: Build and publish python and typescript packages on: push: @@ -30,15 +30,13 @@ jobs: working-directory: ./ts-client steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: "16" - - name: Set version from the gittag + registry-url: "https://registry.npmjs.org" + - name: Set version from the git tag run: npm version ${{ github.ref_name }} - - name: Install dependencies - run: npm install - - name: Build package - run: npm run build + - run: npm ci - name: Publish to npm run: npm publish env: diff --git a/.github/workflows/check-pre-commit.yml b/.github/workflows/check-pre-commit.yml deleted file mode 100644 index ede78870d..000000000 --- a/.github/workflows/check-pre-commit.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Check pre-commit hooks pass - -on: - push: - branches: "**" - -jobs: - check-pre-commit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - name: Install pre-commit - run: pip install pre-commit && pre-commit install - - name: Run pre-commit. This will fail if pre-commit hooks fail. - run: pre-commit run --all-files diff --git a/.github/workflows/pg-docker.yml b/.github/workflows/pg-docker.yml deleted file mode 100644 index f32192646..000000000 --- a/.github/workflows/pg-docker.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Builds and publishes a docker image for the back end database. - -on: - push: - paths: - - database/** - - .github/workflows/pg-docker.yml - branches: [main] - -permissions: - id-token: write - contents: read - packages: write - -jobs: - - build-and-publish-docker-postgres: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./database - env: - IMAGE_NAME: ghcr.io/striveworks/valor/pgvalor - IMAGE_NAME_WITH_COMMIT_HASH: ${IMAGE_NAME}:${{ github.sha }} - steps: - - uses: actions/checkout@v3 - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: build - run: | - docker build . -t ${IMAGE_NAME} - - name: push - run: | - docker push ${IMAGE_NAME} - IMAGE_NAME_WITH_COMMIT_HASH=${IMAGE_NAME}:${{ github.sha }} - docker tag ${IMAGE_NAME} ${IMAGE_NAME_WITH_COMMIT_HASH} - docker push ${IMAGE_NAME_WITH_COMMIT_HASH} - - name: push git tag - if: startsWith(github.ref, 'refs/tags/') - run: | - TAG=$(git describe --tags --abbrev=0) - docker tag ${IMAGE_NAME} ${IMAGE_NAME}:${TAG} - docker push ${IMAGE_NAME}:${TAG} \ No newline at end of file diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml deleted file mode 100644 index b441c7eed..000000000 --- a/.github/workflows/publish-docs.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Builds and publishes docs to GitHub pages - -on: - push: - branches: [main] - paths: - - docs/** - - .github/workflows/publish-docs.yml - - mkdocs.yml - -jobs: - build-and-publish-docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: install api - run: pip install "api/.[test]" - - name: install client - run: pip install "client/.[test]" - - name: install mkdocs and plug-ins - run: pip install -r docs/requirements.txt - - name: generate new swagger docs - run: python docs/scripts/generate_swagger_docs.py - - name: deploy docs to gh - run: mkdocs gh-deploy diff --git a/.github/workflows/stress-test.yml b/.github/workflows/stress-test.yml deleted file mode 100644 index 46ed2ab27..000000000 --- a/.github/workflows/stress-test.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Run stress tests manually via the GitHub Actions UI - -on: - workflow_dispatch: - -permissions: - id-token: write - contents: read - -env: - AWS_ROLE: arn:aws:iam::724664234782:role/Striveworks-Role-github_runner_npe - AWS_REGION: us-east-1 - -jobs: - integration-stress-tests: - env: - COVERAGE_FILE: .coverage.integration-stress-tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: build postgres - run: | - docker build ./database -t pgvalor - - name: setup back end test env - run: docker compose -p valor -f docker-compose.yml -f docker-compose.cicd-override.yml --env-file ./api/.env.testing up --build -d - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: install api - run: pip install -e ".[test]" - working-directory: ./api - - name: install client - run: pip install -e ".[test]" - working-directory: ./client - - run: coverage run --source="api/valor_api,client/valor" -m pytest -v integration_tests/stress_test.py - - run: coverage report - - name: upload coverage report as artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ env.COVERAGE_FILE }} - path: ${{ env.COVERAGE_FILE }} - - run: make stop-env - - run: docker compose -p valor -f docker-compose.yml -f docker-compose.cicd-override.yml --env-file ./api/.env.testing up --build -d - env: - VALOR_SECRET_KEY: ${{ vars.SECRET_KEY }} - VALOR_USERNAME: ${{ vars.USERNAME }} - VALOR_PASSWORD: ${{ vars.PASSWORD }} - - name: sleep to give back end time to spin up - run: sleep 15 - - combine-coverage-report: - needs: [integration-stress-tests] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - run: pip install coverage - - uses: actions/download-artifact@v3 - with: - name: .coverage.integration-stress-tests - - run: coverage combine - - run: coverage report - # https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html - - run: | - coverage json - export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") - echo "total=$TOTAL" >> $GITHUB_ENV - - name: "Make badge" - if: github.ref == 'refs/heads/main' - uses: schneegans/dynamic-badges-action@v1.4.0 - with: - auth: ${{ secrets.GIST_SECRET }} - gistID: 501428c92df8d0de6805f40fb78b1363 - filename: valor-coverage.json - label: Coverage - message: ${{ env.total }}% - minColorRange: 50 - maxColorRange: 90 - valColorRange: ${{ env.total }} diff --git a/.github/workflows/tests-and-coverage.yml b/.github/workflows/tests-and-coverage.yml deleted file mode 100644 index 661a9024b..000000000 --- a/.github/workflows/tests-and-coverage.yml +++ /dev/null @@ -1,184 +0,0 @@ -name: Unit, functional, integration tests and code coverage - -on: - push: - branches: "**" - -permissions: - id-token: write - contents: read - -jobs: - backend-functional-tests: - env: - COVERAGE_FILE: .coverage.backend-functional-tests - runs-on: ubuntu-latest - defaults: - run: - working-directory: . - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: set up postgres - run: | - docker build ./database -t pgvalor - docker run -p 5432:5432 -e POSTGRES_PASSWORD=password -e POSTGRES_DB=valor -d pgvalor - sleep 3 - docker build ./migrations -t migrations - docker run -e POSTGRES_PASSWORD=password -e POSTGRES_HOST=localhost -e POSTGRES_DB=valor -e POSTGRES_USERNAME=postgres -e POSTGRES_PORT=5432 --network "host" migrations - - name: run functional tests - run: | - cd api && pip install ".[test]" - POSTGRES_PASSWORD=password POSTGRES_HOST=localhost POSTGRES_DB=valor POSTGRES_USERNAME=postgres POSTGRES_PORT=5432 coverage run --source=valor_api -m pytest -v tests/functional-tests - env: - POSTGRES_PASSWORD: password - POSTGRES_HOST: localhost - POSTGRES_DB: valor - POSTGRES_USERNAME: postgres - POSTGRES_PORT: 5432 - - run: cd api && coverage report - - name: upload coverage report as artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ env.COVERAGE_FILE }} - path: api/${{ env.COVERAGE_FILE }} - - integration-tests: - env: - COVERAGE_FILE: .coverage.integration-tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: build postgres - run: | - docker build ./database -t pgvalor - - name: setup back end test env - run: docker compose -p valor -f docker-compose.yml -f docker-compose.cicd-override.yml --env-file ./api/.env.testing up --build -d - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: install api - run: pip install -e ".[test]" - working-directory: ./api - - name: install client - run: pip install -e ".[test]" - working-directory: ./client - - run: coverage run --source="api/valor_api,client/valor" -m pytest -v integration_tests/client/* - - run: coverage report - - name: upload coverage report as artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ env.COVERAGE_FILE }} - path: ${{ env.COVERAGE_FILE }} - - name: install javascript client - run: npm install - working-directory: ./ts-client - - name: run javascript client tests - run: npm run test - working-directory: ./ts-client - - run: make stop-env - - run: docker compose -p valor -f docker-compose.yml -f docker-compose.cicd-override.yml --env-file ./api/.env.testing up --build -d - env: - VALOR_SECRET_KEY: ${{ vars.SECRET_KEY }} - VALOR_USERNAME: ${{ vars.USERNAME }} - VALOR_PASSWORD: ${{ vars.PASSWORD }} - - name: sleep to give back end time to spin up - run: sleep 15 - - name: test auth - run: pytest -v integration_tests/auth/* - env: - VALOR_USERNAME_FOR_TESTING: ${{ vars.USERNAME }} - VALOR_PASSWORD_FOR_TESTING: ${{ vars.PASSWORD }} - - backend-unit-tests: - env: - COVERAGE_FILE: .coverage.backend-unit-tests - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./api - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - run: pip install ".[test]" - - run: coverage run --source=valor_api -m pytest -v tests/unit-tests - - run: coverage report - - name: upload coverage report as artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ env.COVERAGE_FILE }} - path: api/${{ env.COVERAGE_FILE }} - - client-unit-tests: - env: - COVERAGE_FILE: .coverage.client-unit-tests - runs-on: ubuntu-latest - strategy: - matrix: - python: ["3.7", "3.8", "3.9", "3.10", "3.11"] - defaults: - run: - working-directory: ./client - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - run: pip install tox - - run: tox -e py - - name: upload coverage report as artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ env.COVERAGE_FILE }} - path: client/${{ env.COVERAGE_FILE }} - - combine-coverage-report: - needs: - [ - backend-functional-tests, - integration-tests, - backend-unit-tests, - client-unit-tests, - ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - run: pip install coverage - - uses: actions/download-artifact@v3 - with: - name: .coverage.backend-unit-tests - - uses: actions/download-artifact@v3 - with: - name: .coverage.client-unit-tests - - uses: actions/download-artifact@v3 - with: - name: .coverage.integration-tests - - uses: actions/download-artifact@v3 - with: - name: .coverage.backend-functional-tests - - run: coverage combine - - run: coverage report -m - # https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html - - run: | - coverage json - export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") - echo "total=$TOTAL" >> $GITHUB_ENV - - name: "Make badge" - if: github.ref == 'refs/heads/main' - uses: schneegans/dynamic-badges-action@v1.4.0 - with: - auth: ${{ secrets.GIST_SECRET }} - gistID: c002bbe8c0e479921401b884f4b9fc53 - filename: valor-coverage.json - label: Coverage - message: ${{ env.total }}% - minColorRange: 50 - maxColorRange: 90 - valColorRange: ${{ env.total }}