Skip to content
Merged

New CI #1479

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions .changeset/cool-corners-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
107 changes: 107 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: 'Setup platforma environment'
Comment thread
vadimpiven marked this conversation as resolved.
description: 'Node.js + pnpm + Turbo S3 cache + Docker logins + pnpm install'

inputs:
node-version:
description: 'Node.js version'
required: false
default: '22'
npmjs-token:
description: 'NPM registry auth token'
required: true
github-token:
description: 'GitHub token for npm.pkg.github.com'
required: true
aws-iam-role:
description: 'AWS IAM role ARN for OIDC. Enables Turbo S3 cache, ECR login.'
required: false
default: ''
aws-region:
description: 'AWS region'
required: false
default: 'eu-central-1'
turbo-s3-bucket:
description: 'S3 bucket for Turbo remote cache'
required: false
default: ''
turbo-team-id:
description: 'Turbo team ID (controls cache directory)'
required: false
default: 'ci-010101'
quay-username:
description: 'Quay.io username for Docker login'
required: false
default: ''
quay-robot-token:
description: 'Quay.io robot token for Docker login'
required: false
default: ''
Comment thread
vadimpiven marked this conversation as resolved.

runs:
using: 'composite'
steps:
- name: Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Enable pnpm via corepack
shell: bash
run: corepack enable pnpm

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "store-path=$(pnpm store path)" >> "$GITHUB_OUTPUT"

- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.store-path }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-store-${{ runner.os }}-

- name: Configure AWS credentials
if: inputs.aws-iam-role != ''
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ inputs.aws-iam-role }}
role-duration-seconds: 3600
aws-region: ${{ inputs.aws-region }}

- name: Login to ECR
if: inputs.aws-iam-role != ''
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'

- name: Login to Quay.io
if: inputs.quay-username != ''
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ inputs.quay-username }}
password: ${{ inputs.quay-robot-token }}

- name: Login to containers.pl-open.science
if: inputs.quay-username != ''
uses: docker/login-action@v3
with:
registry: containers.pl-open.science
username: ${{ inputs.quay-username }}
password: ${{ inputs.quay-robot-token }}

- name: Setup Turbo S3 remote cache
if: inputs.turbo-s3-bucket != ''
uses: milaboratory/github-ci/actions/turborepo/cache-s3@v4
with:
storage-provider: 's3'
storage-path: ${{ inputs.turbo-s3-bucket }}
team-id: ${{ inputs.turbo-team-id }}

- name: Install dependencies
shell: bash
env:
NPMJS_TOKEN: ${{ inputs.npmjs-token }}
NODE_AUTH_TOKEN: ${{ inputs.github-token }}
run: pnpm install --frozen-lockfile --prefer-offline
48 changes: 48 additions & 0 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: _build

on:
workflow_call: {}

env:
BODY_LIMIT: "1048576000"

jobs:
build:
runs-on: dev-pl-sdk
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GH_ZEN_APP_ID }}
private-key: ${{ secrets.GH_ZEN_APP_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 0

- uses: ./.github/actions/setup
with:
npmjs-token: ${{ secrets.NPMJS_TOKEN }}
github-token: ${{ steps.app-token.outputs.token }}
aws-iam-role: ${{ secrets.AWS_CI_IAM_MONOREPO_SIMPLE_ROLE }}
turbo-s3-bucket: ${{ secrets.AWS_CI_TURBOREPO_S3_BUCKET }}
quay-username: ${{ secrets.QUAY_USERNAME }}
quay-robot-token: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Check pnpm-workspace.yaml consistency
run: |
if git diff --name-only origin/main..HEAD | grep -q -E '^pnpm-workspace.yaml$'; then
if ! git diff --name-only origin/main..HEAD | grep -q -E '^pnpm-lock.yaml$'; then
echo "::error::Changes in pnpm-workspace.yaml detected, but no updates in pnpm-lock.yaml"
exit 1
fi
fi

- name: Build
env:
NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PL_DOCKER_REGISTRY_PUSH_TO: "quay.io/milaboratories/pl-containers"
run: pnpm run ci:build:local
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this affect new package releases?
If so, we then get into the situation, when software (ptabler, ptexter) metadata becomes released without proper build/upload of package to our CDN and docker registry. This means we will have inconsistent workflow-tengo SDK package that would 100% break every block that will try to use it.
PL_PKG_DEV=local affects software builds and is designed for local software changes. It intentionally prevents software publication and 'spoils' links to the software in metadata to local paths on a host instead of real URLs.
It is like having file:// link in dependencies of your package.json, pointing to some private package you never published to anyone.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, it's not affect release packages. Before publish we run ci:build

89 changes: 89 additions & 0 deletions .github/workflows/_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: _test

on:
workflow_call: {}

env:
BODY_LIMIT: "1048576000"

jobs:
test:
runs-on: dev-pl-sdk
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GH_ZEN_APP_ID }}
private-key: ${{ secrets.GH_ZEN_APP_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 0

- uses: ./.github/actions/setup
with:
npmjs-token: ${{ secrets.NPMJS_TOKEN }}
github-token: ${{ steps.app-token.outputs.token }}
aws-iam-role: ${{ secrets.AWS_CI_IAM_MONOREPO_SIMPLE_ROLE }}
turbo-s3-bucket: ${{ secrets.AWS_CI_TURBOREPO_S3_BUCKET }}
quay-username: ${{ secrets.QUAY_USERNAME }}
quay-robot-token: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Restore changeset version state
if: >-
(github.event_name == 'push' && github.ref_name == 'main')
|| github.event_name == 'pull_request'
|| github.event_name == 'merge_group'
run: pnpm run version-packages

- name: Rebuild from Turbo cache
env:
NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PL_DOCKER_REGISTRY_PUSH_TO: "quay.io/milaboratories/pl-containers"
run: pnpm run ci:build:local

- name: Check test cache (dry-run)
id: dry-run
run: |
pnpm run test:local+dry-run > ./test-dry-run.json || true
SKIP_TESTS=$(sed -n '/^{/,$p' ./test-dry-run.json | jq -r '.tasks | map(select(.task == "test")) | all((.cache.status == "HIT") or (.cache.status == "MISS" and .command == "<NONEXISTENT>"))' 2>/dev/null || echo "false")
echo "skip=$SKIP_TESTS" >> "$GITHUB_OUTPUT"
echo "Test cache skip: $SKIP_TESTS"

- name: Login to ECR
if: steps.dry-run.outputs.skip != 'true'
id: ecr-login
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: "true"

- name: Start Platforma Docker
if: steps.dry-run.outputs.skip != 'true'
uses: milaboratory/github-ci/actions/docker/pl-compose@v4
with:
pl-docker-registry: ${{ format('{0}/{1}', steps.ecr-login.outputs.registry, 'pl') }}
pl-docker-tag: main
pl-test-assets-dir: assets
pl-log-level: info

- name: Run tests
if: steps.dry-run.outputs.skip != 'true'
env:
PL_ADDRESS: "http://127.0.0.1:6345"
PL_TEST_USER: ${{ secrets.PL_CI_TEST_USER }}
PL_TEST_PASSWORD: ${{ secrets.PL_CI_TEST_PASSWORD }}
PL_LICENSE: ${{ secrets.MI_LICENSE }}
MI_LICENSE: ${{ secrets.MI_LICENSE }}
NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm run ci:test:local
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially, the same story as for builds for releases.
Tests are run over some backend that is started as a separate process. In remote K8S, or as a docker container with docker-compose. This means, any reference to software that contains local path on a current runner would not exist on remote backend side.

I don't say this would never work. I just show a warn flag this is a thing to check. I.e., by adding chages to some python code of ptabler/ptexter we publish from monorepo (if we still do so).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario hasn't changed, this logic has always had this command


- name: Upload coverage
if: always()
uses: milaboratory/github-ci/actions/node/upload-coverage@v4
with:
test-coverage-reports: "**/coverage/lcov.info"
test-results-reports: "**/test-report.junit.xml"
77 changes: 0 additions & 77 deletions .github/workflows/build.yaml

This file was deleted.

67 changes: 0 additions & 67 deletions .github/workflows/build_run_all_tests.yaml

This file was deleted.

Loading
Loading