diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml deleted file mode 100644 index 9e3f1ce6..00000000 --- a/.github/workflows/build-docs.yml +++ /dev/null @@ -1,119 +0,0 @@ -name: Build and Deploy Docs - -on: - push: - branches: - - main - - 'v*' - tags: - - 'v*' - -jobs: - build-deploy-docs: - runs-on: ubuntu-latest - - steps: - - name: Checkout Product Repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set Variables Based on Ref - id: vars - run: | - PRODUCT_NAME=$(basename $(pwd)) # Get the directory name as the product name - echo "PRODUCT_NAME=$PRODUCT_NAME" >> $GITHUB_ENV - CURRENT_REF=${GITHUB_REF##*/} - IS_SEMVER=false - SEMVER_REGEX="^v([0-9]+)\.([0-9]+)\.([0-9]+)$" - - if [[ "${GITHUB_REF_TYPE}" == "branch" ]]; then - if [[ "$CURRENT_REF" == "main" ]]; then - echo "VERSION=main" >> $GITHUB_ENV - echo "BRANCH=main" >> $GITHUB_ENV - elif [[ "$CURRENT_REF" =~ $SEMVER_REGEX ]]; then - IS_SEMVER=true - echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV - echo "BRANCH=$CURRENT_REF" >> $GITHUB_ENV - else - echo "Branch '$CURRENT_REF' is not a valid semantic version. Skipping build." - exit 0 - fi - elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then - if [[ "$CURRENT_REF" =~ $SEMVER_REGEX ]]; then - IS_SEMVER=true - echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV - echo "BRANCH=main" >> $GITHUB_ENV # Set BRANCH to 'main' for tags - else - echo "Tag '$CURRENT_REF' is not a valid semantic version. Skipping build." - exit 0 - fi - fi - - # Gather branches and tags, filter for semantic versions, sort, remove duplicates - VERSIONS=$(git for-each-ref refs/remotes/origin refs/tags --format="%(refname:short)" | \ - grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | sort -Vr | uniq | tr '\n' ',' | sed 's/,$//') - echo "VERSIONS=main,$VERSIONS" >> $GITHUB_ENV - - - name: Install Hugo - run: | - wget https://github.com/gohugoio/hugo/releases/download/v0.79.1/hugo_extended_0.79.1_Linux-64bit.tar.gz - tar -xzvf hugo_extended_0.79.1_Linux-64bit.tar.gz - sudo mv hugo /usr/local/bin/ - - - name: Checkout Docs Repo - uses: actions/checkout@v2 - with: - repository: infinilabs/docs - path: docs-output - token: ${{ secrets.DOCS_DEPLOYMENT_TOKEN }} - - - name: Build Documentation - run: | - (cd docs && OUTPUT=$(pwd)/../docs-output make docs-build docs-place-redirect) - - - name: Commit and Push Changes to Docs Repo - working-directory: docs-output - run: | - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - if [[ -n $(git status --porcelain) ]]; then - git add . - git commit -m "Rebuild $PRODUCT_NAME docs for version $VERSION" - git push origin main - else - echo "No changes to commit." - fi - - - name: Rebuild Docs for Latest Version (main), if not already on main - run: | - # Only rebuild the main branch docs if the current ref is not "main" - if [[ "$CURRENT_REF" != "main" ]]; then - echo "Switching to main branch and rebuilding docs for 'latest'" - - # Checkout the main branch of the product repo to rebuild docs for "latest" - git checkout main - - # Ensure the latest changes are pulled - git pull origin main - - # Build Docs for Main Branch (latest) - (cd docs && OUTPUT=$(pwd)/../docs-output VERSION="main" BRANCH="main" make docs-build docs-place-redirect) - - # Commit and Push Latest Docs to Main - cd docs-output - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - if [[ -n $(git status --porcelain) ]]; then - git add . - git commit -m "Rebuild $PRODUCT_NAME docs for main branch with latest version" - git push origin main - else - echo "No changes to commit for main." - fi - else - echo "Current ref is 'main', skipping rebuild for 'latest'." - fi - working-directory: ./ # Working in the product repo diff --git a/.github/workflows/commit-message-check.yml b/.github/workflows/commit-message-check.yml deleted file mode 100644 index 98cf2279..00000000 --- a/.github/workflows/commit-message-check.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: 'commit-message-check' -on: - pull_request: - -jobs: - check-commit-message: - name: check-subject - runs-on: ubuntu-latest - steps: - - name: check-subject-type - uses: gsactions/commit-message-checker@v2 - with: - checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request - excludeDescription: 'true' # optional: this excludes the description body of a pull request - accessToken: ${{ secrets.GITHUB_TOKEN }} - pattern: '^(change:|feat:|improve:|perf:|dep:|docs:|test:|ci:|style:|refactor:|fix:|fixdoc:|fixup:|merge|Merge|update|Update|bumpver:|chore:|build:) .+$' - flags: 'gm' - error: | - Subject line has to contain a commit type, e.g.: "chore: blabla" or a merge commit e.g.: "merge xxx". - Valid types are: - change - API breaking change - feat - API compatible new feature - improve - Become better without functional changes - perf - Performance improvement - dep - dependency update - docs - docs update - test - test udpate - ci - CI workflow update - refactor - refactor without function change. - fix - fix bug - fixdoc - fix doc - fixup - minor change: e.g., fix sth mentioned in a review. - bumpver - Bump to a new version. - chore - Nothing important. - build - bot: dependabot. \ No newline at end of file diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml new file mode 100644 index 00000000..4404e51d --- /dev/null +++ b/.github/workflows/integration_test.yml @@ -0,0 +1,84 @@ +name: Integration test + +env: + GO_VERSION: 1.23.4 + NODEJS_VERSION: 20.18.2 + PNPM_VERSION: 'latest' + ES_ADMIN_PASSWORD: 'F0r_test_ci' + +on: + pull_request: + +jobs: + integration_test: + runs-on: ubuntu-latest + + steps: + # - name: Checkout current repository + # uses: actions/checkout@v4 + + # - name: Checkout framework repository + # uses: actions/checkout@v4 + # with: + # repository: infinilabs/framework + # path: framework + + # - name: Checkout framework-vendor + # uses: actions/checkout@v4 + # with: + # ref: main + # repository: infinilabs/framework-vendor + # path: vendor + + # - name: Set up nodejs toolchain + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.NODEJS_VERSION }} + + # - name: Check nodejs toolchain + # run: | + # if ! command -v pnpm >/dev/null 2>&1; then + # npm install -g pnpm + # fi + # node -v && npm -v && pnpm -v + + # - name: Set up go toolchain + # uses: actions/setup-go@v5 + # with: + # go-version: ${{ env.GO_VERSION }} + # check-latest: false + # cache: true + + # # I have no idea why ./bin/initialize.sh does not accept this var when + # # I set it via + # # + # # $ EASYSEARCH_INITIAL_ADMIN_PASSWORD=${{ env.ES_ADMIN_PASSWORD }} ./bin/initialize.sh + # # + # # So I have to set it here, in a separate step + # - name: Set env var EASYSEARCH_INITIAL_ADMIN_PASSWORD + # run: echo "EASYSEARCH_INITIAL_ADMIN_PASSWORD=${{ env.ES_ADMIN_PASSWORD }}" >> $GITHUB_ENV + + # - name: Set up Easysearch + # run: | + # mkdir ~/es_install_dir + # curl -sSL http://get.infini.cloud | bash -s -- -p easysearch -d ~/es_install_dir + # cd ~/es_install_dir && ./bin/initialize.sh -s + # cd ~/es_install_dir && nohup ./bin/easysearch > easysearch.log 2>&1 & + # while ! nc -z 127.0.0.1 9200; do + # echo "Easysearch is not up. Will re-check in 5 seconds..." + # sleep 5 + # done + # curl -k -u admin:${{env.ES_ADMIN_PASSWORD}} https://127.0.0.1:9200 + + - name: Install Loadgen + run: | + mkdir ~/loadgen_install_dir + curl -sSL http://get.infini.cloud | bash -s -- -p loadgen -d ~/loadgen_install_dir + # Move to binary to /usr/bin so that it is in $PATH + sudo mv ~/loadgen_install_dir/loadgen-linux-* /usr/bin/loadgen + # Make sure it is executable, just in case. + chmod +x /usr/bin/loadgen + # Run it to verify it is installed + loadgen + # Clear the log directory created by Loadgen + rm -r log diff --git a/.github/workflows/osv-scanner.yml b/.github/workflows/osv-scanner.yml deleted file mode 100644 index a0b639b7..00000000 --- a/.github/workflows/osv-scanner.yml +++ /dev/null @@ -1,34 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# A sample workflow which sets up periodic OSV-Scanner scanning for vulnerabilities, -# in addition to a PR check which fails if new vulnerabilities are introduced. -# -# For more examples and options, including how to ignore specific vulnerabilities, -# see https://google.github.io/osv-scanner/github-action/ - -name: OSV-Scanner - -on: - pull_request: - branches: [ "main" ] - -permissions: - # Required to upload SARIF file to CodeQL. See: https://github.com/github/codeql-action/issues/2117 - actions: read - # Require writing security events to upload SARIF file to security tab - security-events: write - # Only need to read contents - contents: read - -jobs: - scan-pr: - uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.0.2" - with: - fail-on-vuln: false - scan-args: |- - --recursive - --skip-git - /github/workspace diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml deleted file mode 100644 index aa9ec80c..00000000 --- a/.github/workflows/unit_test.yml +++ /dev/null @@ -1,342 +0,0 @@ -name: Unit Test - -on: - pull_request: - branches: [ "main" ] - -defaults: - run: - shell: bash - -env: - PNAME: coco - GO_VERSION: 1.23.4 - NODEJS_VERSION: 20.18.2 - PNPM_VERSION: 'latest' - -jobs: - format_check: - runs-on: ubuntu-latest - steps: - - name: Checkout current repository - uses: actions/checkout@v4 - with: - path: ${{ env.PNAME }} - - - name: Checkout framework repository - uses: actions/checkout@v4 - with: - repository: infinilabs/framework - path: framework - - - name: Checkout framework-vendor - uses: actions/checkout@v4 - with: - ref: main - repository: infinilabs/framework-vendor - path: vendor - - - name: Set up nodejs toolchain - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODEJS_VERSION }} - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - node_modules - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: Check nodejs toolchain - run: | - if ! command -v pnpm >/dev/null 2>&1; then - npm install -g pnpm - fi - node -v && npm -v && pnpm -v - - - name: Set up go toolchain - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - check-latest: false - cache: true - - - name: Check go toolchain - run: go version - - - name: Cache Build Output - uses: actions/cache@v4 - with: - path: | - .public - key: ${{ runner.os }}-build-${{ hashFiles('**/package.json') }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-build-${{ hashFiles('**/package.json') }}- - ${{ runner.os }}-build- - - - name: Code format - env: - GOFLAGS: -tags=ci - run: | - echo Home path is $HOME - export WORKBASE=$HOME/go/src/infini.sh - export WORK=$WORKBASE/$PNAME - - # for test workspace - mkdir -p $HOME/go/src/ - ln -s $GITHUB_WORKSPACE $WORKBASE - - # for web build - cd $WORK/web && sed -i '/prepare/d' package.json - pnpm install --registry=https://registry.npmjs.com --quiet && pnpm build -- --silent - - # check work folder - ls -lrt $WORKBASE/ - ls -alrt $WORK - - # for code format - cd $WORK - echo Formating code at $PWD ... - make format - if [ $? -ne 0 ]; then - echo "make format failed, please check make output" - exit 1 - fi - - - name: Check for changes after format - id: check-changes - shell: bash - run: | - export WORKBASE=$HOME/go/src/infini.sh - export WORK=$WORKBASE/$PNAME - - # for foramt check - cd $WORK - if [[ $(git status --porcelain | grep -c " M .*\.go$") -gt 0 ]]; then - echo "go format detected formatting changes" - echo "changes=true" >> $GITHUB_OUTPUT - else - echo "go format no changes found" - echo "changes=false" >> $GITHUB_OUTPUT - fi - - - name: Fail workflow if changes after format - if: steps.check-changes.outputs.changes == 'true' - run: | - export WORKBASE=$HOME/go/src/infini.sh - export WORK=$WORKBASE/$PNAME - - # for foramt check - cd $WORK && echo - git status --porcelain | grep " M .*\.go$" - echo "----------------------------------------------------------------------------------" - echo "IMPORTANT: Above files are not formatted, please run 'make format' to format them." - echo "----------------------------------------------------------------------------------" - exit 1 - - unit_test: - runs-on: ubuntu-latest - steps: - - name: Checkout current repository - uses: actions/checkout@v4 - with: - path: ${{ env.PNAME }} - - - name: Checkout framework repository - uses: actions/checkout@v4 - with: - repository: infinilabs/framework - path: framework - - - name: Checkout framework-vendor - uses: actions/checkout@v4 - with: - ref: main - repository: infinilabs/framework-vendor - path: vendor - - - name: Set up nodejs toolchain - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODEJS_VERSION }} - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - node_modules - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: Check nodejs toolchain - run: | - if ! command -v pnpm >/dev/null 2>&1; then - npm install -g pnpm - fi - node -v && npm -v && pnpm -v - - - name: Set up go toolchain - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - check-latest: false - cache: true - - - name: Check go toolchain - run: go version - - - name: Cache Build Output - uses: actions/cache@v4 - with: - path: | - .public - key: ${{ runner.os }}-build-${{ hashFiles('**/package.json') }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-build-${{ hashFiles('**/package.json') }}- - ${{ runner.os }}-build- - - - name: Unit test - env: - GOFLAGS: -tags=ci - run: | - echo Home path is $HOME - export WORKBASE=$HOME/go/src/infini.sh - export WORK=$WORKBASE/$PNAME - - # for test workspace - mkdir -p $HOME/go/src/ - ln -s $GITHUB_WORKSPACE $WORKBASE - - # for web build - echo "Build $PNAME web start..." - cd $WORK/web && sed -i '/prepare/d' package.json - pnpm install --registry=https://registry.npmjs.com --quiet && pnpm build -- --silent - - # check work folder - ls -lrt $WORKBASE/ - ls -alrt $WORK - - # for unit test - cd $WORK - echo Testing code at $PWD ... - OFFLINE_BUILD=true CI=true make test - - code_lint: - runs-on: ubuntu-latest - steps: - - name: Checkout current repository - uses: actions/checkout@v4 - with: - path: ${{ env.PNAME }} - - - name: Checkout framework repository - uses: actions/checkout@v4 - with: - repository: infinilabs/framework - path: framework - - - name: Checkout framework-vendor - uses: actions/checkout@v4 - with: - ref: main - repository: infinilabs/framework-vendor - path: vendor - - - name: Set up nodejs toolchain - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODEJS_VERSION }} - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - node_modules - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: Check nodejs toolchain - run: | - if ! command -v pnpm >/dev/null 2>&1; then - npm install -g pnpm - fi - node -v && npm -v && pnpm -v - - - name: Set up go toolchain - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - check-latest: false - cache: true - - - name: Check go toolchain - run: go version - - - name: Cache Build Output - uses: actions/cache@v4 - with: - path: | - .public - key: ${{ runner.os }}-build-${{ hashFiles('**/package.json') }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-build-${{ hashFiles('**/package.json') }}- - ${{ runner.os }}-build- - - - name: Code lint - env: - GOFLAGS: -tags=ci - run: | - echo Home path is $HOME - export WORKBASE=$HOME/go/src/infini.sh - export WORK=$WORKBASE/$PNAME - - # for test workspace - mkdir -p $HOME/go/src/ - ln -s $GITHUB_WORKSPACE $WORKBASE - - # for web build - echo "Build $PNAME web start..." - cd $WORK/web && sed -i '/prepare/d' package.json - pnpm install --registry=https://registry.npmjs.com --quiet && pnpm build -- --silent - - # check work folder - ls -lrt $WORKBASE/ - ls -alrt $WORK - - # for code lint - cd $WORK - echo Linting code at $PWD ... - # make lint - - web_test: - runs-on: ubuntu-latest - steps: - - name: Checkout current repository - uses: actions/checkout@v4 - with: - path: ${{ env.PNAME }} - - - name: Set up nodejs toolchain - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODEJS_VERSION }} - cache: 'npm' - cache-dependency-path: "**/package.json" - - - name: Check nodejs toolchain - run: | - if ! command -v pnpm >/dev/null 2>&1; then - npm install -g pnpm - fi - node -v && npm -v && pnpm -v - - - name: Check web build - run: | - echo Home path is $HOME - cd $GITHUB_WORKSPACE/$PNAME/web - pnpm install --registry=https://registry.npmjs.com --quiet && pnpm build -- --silent