From b595f51358c7ca8c887dee04a54f48542dba0aeb Mon Sep 17 00:00:00 2001 From: Nasser Anssari Date: Tue, 22 Oct 2024 11:59:43 +0300 Subject: [PATCH] chore: cleanup GH actions (#790) --- .github/workflows/core-release.yaml | 91 --------------- .github/workflows/core-upgrade.yaml | 105 ------------------ .../workflows/generator-download-specs.yaml | 20 ---- .github/workflows/generator-test-sdk.yaml | 10 +- .github/workflows/pr-check-tests.yaml | 3 +- .github/workflows/run-tests.yaml | 70 +----------- 6 files changed, 11 insertions(+), 288 deletions(-) delete mode 100644 .github/workflows/core-release.yaml delete mode 100644 .github/workflows/core-upgrade.yaml delete mode 100644 .github/workflows/generator-download-specs.yaml diff --git a/.github/workflows/core-release.yaml b/.github/workflows/core-release.yaml deleted file mode 100644 index ac2ea70c3..000000000 --- a/.github/workflows/core-release.yaml +++ /dev/null @@ -1,91 +0,0 @@ -name: Release SDK Core - -on: - workflow_dispatch: - inputs: - production_release: - description: '(!!!) Release to production' - required: true - type: boolean - default: false - upgrade_type: - description: 'Upgrade Type. Choose none to skip upgrade' - type: choice - options: - - 'major' - - 'minor' - - 'patch' - - 'none' - -jobs: - upgrade: - uses: ./.github/workflows/core-upgrade.yaml - with: - upgrade_type: ${{ github.event.inputs.upgrade_type }} - secrets: - GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - - release: - if: always() - needs: [ upgrade ] - runs-on: ubuntu-latest - steps: - - name: Download branch name - uses: actions/download-artifact@v4 - with: - name: branch-name - continue-on-error: true - - - name: Set branch name - id: set_branch - run: | - if [ -f branch_name.txt ]; then - BRANCH_NAME=$(cat branch_name.txt) - else - BRANCH_NAME="${GITHUB_REF#refs/heads/}" - fi - echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV - echo "BRANCH_NAME=$BRANCH_NAME" - - - uses: actions/checkout@v4 - with: - ref: ${{ env.BRANCH_NAME }} - - - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: '21' - server-id: oss-sonatype - server-username: SONATYPE_USERNAME - server-password: SONATYPE_PASSWORD - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg-passphrase: GPG_PASSPHRASE - settings-path: ${{ github.workspace }} - - - name: Generate SDK - working-directory: core - run: | - mvn clean install -DskipTests -B -U - - - name: "Release artifacts" - working-directory: core - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - GPG_PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }} - run: | - if ${{github.event.inputs.production_release}}; then - echo "Releasing to production" - exit 1 # Debugging - mvn deploy --settings $GITHUB_WORKSPACE/settings.xml -B -U -P release - echo ">> SonaType release URL: https://repo1.maven.org/maven2/com/expediagroup/sdk-core/" - else - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) - SNAPSHOT_VERSION="${VERSION%-SNAPSHOT}-SNAPSHOT" - echo "Releasing as snapshot" - mvn versions:set -DnewVersion=$SNAPSHOT_VERSION - mvn deploy --settings $GITHUB_WORKSPACE/settings.xml -B -U -P release - echo ">> SonaType snapshots URL: https://oss.sonatype.org/content/repositories/snapshots/com/expediagroup/sdk-core/" - fi - echo ">> v$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) released" - echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/core-upgrade.yaml b/.github/workflows/core-upgrade.yaml deleted file mode 100644 index f4073662f..000000000 --- a/.github/workflows/core-upgrade.yaml +++ /dev/null @@ -1,105 +0,0 @@ -name: Upgrade SDK Core - -on: - workflow_call: - inputs: - upgrade_type: - description: 'Upgrade Type. Options: major, minor, patch, none' - required: true - type: string - default: 'none' - secrets: - GH_PERSONAL_ACCESS_TOKEN: - description: 'GitHub Personal Access Token' - required: true - -jobs: - upgrade: - permissions: - contents: write - pull-requests: write - - runs-on: ubuntu-latest - - steps: - - name: Confirm Upgrade - run: | - if [ "${{ github.event.inputs.upgrade_type }}" == "none" ]; then - echo "Upgrade not requested. Skipping." - exit 1 - else - echo "Upgrade requested. Proceeding." - fi - - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: '21' - - - name: Increment version - working-directory: core - id: increment_version - run: | - version=$(mvn -q \ - -Dexec.executable=echo \ - -Dexec.args='${project.version}' \ - --non-recursive \ - exec:exec) - IFS='.' read -ra VERSION_PARTS <<< "$version" - MAJOR=${VERSION_PARTS[0]} - MINOR=${VERSION_PARTS[1]} - PATCH=${VERSION_PARTS[2]} - - echo "Upgrade type: ${{ github.event.inputs.upgrade_type }}" - echo "Major: $MAJOR" - echo "Minor: $MINOR" - echo "Patch: $PATCH" - case "${{ github.event.inputs.upgrade_type }}" in - "major") - MAJOR=$(expr $MAJOR + 1) - MINOR=0 - PATCH=0 - ;; - "minor") - MINOR=$(expr $MINOR + 1) - PATCH=0 - ;; - "patch") - PATCH=$(expr $PATCH + 1) - ;; - *) - echo "Invalid upgrade type. Must be one of: major, minor, patch." - exit 1 - ;; - esac - - NEW_VERSION="$MAJOR.$MINOR.$PATCH" - echo "New version: $NEW_VERSION" - mvn versions:set -DnewVersion=$NEW_VERSION - echo "version=$NEW_VERSION" >> $GITHUB_ENV - - - name: Commit changes - run: | - git config --global user.email "oss@expediagroup.com" - git config --global user.name "eg-oss-ci" - git commit -am "chore: upgrade core version to ${{ env.version }}" - echo "branch_name=upgrade-core-to-v${{ env.version }}" >> $GITHUB_ENV - echo "upgrade-core-to-v${{ env.version }}" > branch_name.txt - - - name: Upload branch name - uses: actions/upload-artifact@v4 - with: - name: branch-name - path: branch_name.txt - overwrite: true - - - name: Publish Updated Version PR - uses: peter-evans/create-pull-request@v7 - with: - token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - commit-message: "chore: upgrade core version to ${{ env.version }}" - title: "chore: upgrade core version to ${{ env.version }}" - branch: ${{ env.branch_name }} - body: "This PR upgrades the core version to ${{ env.version }}." diff --git a/.github/workflows/generator-download-specs.yaml b/.github/workflows/generator-download-specs.yaml deleted file mode 100644 index 9d8160171..000000000 --- a/.github/workflows/generator-download-specs.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: Download API Specs -on: - workflow_call: - inputs: - url: - description: 'URL to download API specs from' - required: true - type: string - -jobs: - download_specs: - runs-on: ubuntu-latest - steps: - - id: download_specs - run: | - curl -L ${{ inputs.url }} -o raw-specs.yaml - - uses: actions/upload-artifact@v4 - with: - name: raw-specs - path: raw-specs.yaml diff --git a/.github/workflows/generator-test-sdk.yaml b/.github/workflows/generator-test-sdk.yaml index 74e613257..d1c5c91cd 100644 --- a/.github/workflows/generator-test-sdk.yaml +++ b/.github/workflows/generator-test-sdk.yaml @@ -10,14 +10,14 @@ on: description: 'SDK to generate test jar for' required: true type: string - endpoint_prefix: - description: 'Endpoint to prepend specs paths with' - required: true - type: string product_repo: description: 'Product repository' required: true type: string + transformations: + description: 'Specs transformations' + required: true + type: string outputs: artifactId: value: ${{ jobs.sdk-metadata.outputs.artifactId }} @@ -30,7 +30,7 @@ jobs: transform-specs: uses: ./.github/workflows/selfserve-transform-specs.yaml with: - transformations: '-th -te ${{ inputs.endpoint_prefix }} --operationIdsToTags' + transformations: ${{ inputs.transformations }} repository: ${{ inputs.product_repo }} ref: 'main' diff --git a/.github/workflows/pr-check-tests.yaml b/.github/workflows/pr-check-tests.yaml index d2048fa0a..55e643f7c 100644 --- a/.github/workflows/pr-check-tests.yaml +++ b/.github/workflows/pr-check-tests.yaml @@ -5,9 +5,8 @@ jobs: run-rapid-tests: uses: ./.github/workflows/run-tests.yaml with: - source: 'specs' sdk_version: 1.0.${{ github.run_id }} sdk_namespace: 'rapid' - endpoint_prefix: '/v3' + transformations: '-th -te /v3 --operationIdsToTags' product_repo: 'ExpediaGroup/rapid-java-sdk' secrets: inherit diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 8e3b79419..29a87808c 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -1,56 +1,7 @@ name: Run Tests on: - workflow_dispatch: - inputs: - source: - description: 'Source of tests' - required: true - type: choice - options: - - 'specs' - - 'sdk' - default: 'sdk' - specs_url: - description: 'Run tests based on specs' - required: false - type: string - default: '' - sdk_version: - description: 'Run tests based on SDK' - required: false - type: string - default: 'LATEST' - sdk_namespace: - description: 'SDK to test' - required: true - type: string - default: 'rapid' - endpoint_prefix: - description: 'Endpoint to prepend specs paths with' - required: true - type: string - jdk: - description: 'JDK version to use' - required: true - type: choice - options: - - '21' - - '17' - - '11' - - '8' - default: '21' workflow_call: inputs: - source: - description: 'Source of tests' - required: true - type: string - default: 'sdk' - specs_url: - description: 'Run tests based on specs' - required: false - type: string - default: '' sdk_version: description: 'Run tests based on SDK' required: false @@ -61,8 +12,8 @@ on: required: true type: string default: 'rapid' - endpoint_prefix: - description: 'Endpoint to prepend specs paths with' + transformations: + description: 'Specs transformations' required: true type: string product_repo: @@ -71,31 +22,20 @@ on: type: string jobs: - inputs-validation: - runs-on: ubuntu-latest - steps: - - shell: python -u {0} - run: | - if 'sdk' in '${{ inputs.source }}' and not('${{ inputs.sdk_version }}'): - print('::error::Invalid SDK version: ${{ inputs.sdk_version }}') - exit(1) - generate-test-sdk: - if: inputs.source == 'specs' - needs: [ inputs-validation ] uses: ./.github/workflows/generator-test-sdk.yaml + secrets: inherit with: version: ${{ inputs.sdk_version }} namespace: ${{ inputs.sdk_namespace }} - endpoint_prefix: ${{ inputs.endpoint_prefix }} product_repo: ${{ inputs.product_repo }} + transformations: ${{ inputs.transformations }} - secrets: inherit run-rapid-examples: strategy: matrix: jdk: [8, 11, 17, 21] - if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && inputs.sdk_namespace == 'rapid' + if: inputs.sdk_namespace == 'rapid' needs: [ generate-test-sdk ] uses: "ExpediaGroup/rapid-java-sdk/.github/workflows/run-examples.yaml@main" with: