From e1d75deb3130f7c1e33b777a8a9fcd092add418a Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Tue, 14 Feb 2023 23:49:03 +0000 Subject: [PATCH 1/4] Add test --- .github/workflows/test-action-local.yml | 30 +++++++++++++++++++++++-- tests/test-maven.txt | 21 +++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 tests/test-maven.txt diff --git a/.github/workflows/test-action-local.yml b/.github/workflows/test-action-local.yml index 17b9cc3..7448985 100644 --- a/.github/workflows/test-action-local.yml +++ b/.github/workflows/test-action-local.yml @@ -18,8 +18,13 @@ jobs: command_line: cat tests/test2.txt contains: MathieuSoysal/file-updater-for-release@v1.0.0 + - uses: GuillaumeFalourd/assert-command-line-output@v2 + with: + command_line: cat tests/test-maven.txt + contains: cloud.tools:jib-maven-plugin:3.2.1 + test-for-github-workflow: # Test the action with the GitHub workflow - name: Test update-readme-files action + name: Test update dependency needs: check-files continue-on-error: true runs-on: ubuntu-latest @@ -43,4 +48,25 @@ jobs: uses: GuillaumeFalourd/assert-command-line-output@v2 with: command_line: cat tests/test2.txt - contains: MathieuSoysal/file-updater-for-release@v1.0.3 \ No newline at end of file + contains: MathieuSoysal/file-updater-for-release@v1.0.3 + + + + # Test with a specific kind tag + + - name: Test kind of tag + uses: ./ + with: + files: tests/test-maven.txt + github_repository: GoogleContainerTools/jib + prefix: "cloud.tools:jib-maven-plugin:" + suffix: ":build ." + regex: "[0-9.]*" + selector: maven + + - name: Test if file has been updated + uses: GuillaumeFalourd/assert-command-line-output@v2 + with: + command_line: cat tests/test-maven.txt + contains: cloud.tools:jib-maven-plugin:3.2.1 + expected_result: FAILED \ No newline at end of file diff --git a/tests/test-maven.txt b/tests/test-maven.txt new file mode 100644 index 0000000..b8a9419 --- /dev/null +++ b/tests/test-maven.txt @@ -0,0 +1,21 @@ + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: ${{ inputs.java-distribution }} + java-version: ${{ inputs.java-version }} + cache: maven + + - name: Build JIB container and publish to GitHub Packages + run: | + if [ ! -z "${{ inputs.module }}" ]; then + MULTI_MODULE_ARGS="-am -pl ${{ inputs.module }}" + fi + if [ ! -z "${{ inputs.main-class }}" ]; then + MAIN_CLASS_ARGS="-Djib.container.mainClass=${{ inputs.main-class }}" + fi + mvn package com.google.cloud.tools:jib-maven-plugin:3.2.1:build \ + -Djib.to.image=${{ inputs.REGISTRY }}/${{ steps.downcase.outputs.lowercase }}:${{ inputs.tag-name }} \ + -Djib.to.auth.username=${{ inputs.USERNAME }} \ + -Djib.to.auth.password=${{ inputs.PASSWORD }} $MULTI_MODULE_ARGS $MAIN_CLASS_ARGS + shell: bash \ No newline at end of file From e23a6af091ee8ac886b611781c219f7ea3591faa Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Tue, 14 Feb 2023 23:50:12 +0000 Subject: [PATCH 2/4] Update test --- .github/workflows/test-action-final.yml | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-action-final.yml b/.github/workflows/test-action-final.yml index 53272b7..2c926d2 100644 --- a/.github/workflows/test-action-final.yml +++ b/.github/workflows/test-action-final.yml @@ -18,8 +18,13 @@ jobs: command_line: cat tests/test2.txt contains: MathieuSoysal/file-updater-for-release@v1.0.0 + - uses: GuillaumeFalourd/assert-command-line-output@v2 + with: + command_line: cat tests/test-maven.txt + contains: cloud.tools:jib-maven-plugin:3.2.1 + test-for-github-workflow: # Test the action with the GitHub workflow - name: Test update-readme-files action + name: Test update dependency needs: check-files continue-on-error: true strategy: @@ -47,3 +52,24 @@ jobs: with: command_line: cat tests/test2.txt contains: MathieuSoysal/file-updater-for-release@v1.0.3 + + + + # Test with a specific kind tag + + - name: Test kind of tag + uses: ./ + with: + files: tests/test-maven.txt + github_repository: GoogleContainerTools/jib + prefix: "cloud.tools:jib-maven-plugin:" + suffix: ":build ." + regex: "[0-9.]*" + selector: maven + + - name: Test if file has been updated + uses: GuillaumeFalourd/assert-command-line-output@v2 + with: + command_line: cat tests/test-maven.txt + contains: cloud.tools:jib-maven-plugin:3.2.1 + expected_result: FAILED \ No newline at end of file From 7ee0edb8f2841e7943d7be5b87493a04816139f7 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Tue, 14 Feb 2023 23:50:22 +0000 Subject: [PATCH 3/4] Update action.yml --- action.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4ae44e8..2f995a5 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,11 @@ inputs: description: "Github repository to get the latest tag" required: true type: string + selector: # selector to get a particular kind of tag in many kind of tags + description: "Selector to get the latest tag" + required: true + default: "" + type: string @@ -47,7 +52,9 @@ runs: id: get_new_tag shell: bash run: | - temp_result=$(curl -s https://api.github.com/repos/${{ inputs.github_repository }}/tags | grep -h "name" | head -1 | grep -ho "${{inputs.regex}}") + temp_result=$(curl -s https://api.github.com/repos/${{inputs.github_repository}}/tags | grep -h "name" | grep -h "${{inputs.selector}}" | head -1 | grep -ho "${{inputs.regex}}") + echo "${temp_result}" + echo "${temp_result}" echo "new-tag=${temp_result}" >> $GITHUB_OUTPUT - name: update files From b8a657c5e948bbe8f2bdb5e0e346ecd8df74729e Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Wed, 15 Feb 2023 00:05:24 +0000 Subject: [PATCH 4/4] Remove obsolete code in action.yml --- action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/action.yml b/action.yml index 2f995a5..5aa0d47 100644 --- a/action.yml +++ b/action.yml @@ -53,8 +53,6 @@ runs: shell: bash run: | temp_result=$(curl -s https://api.github.com/repos/${{inputs.github_repository}}/tags | grep -h "name" | grep -h "${{inputs.selector}}" | head -1 | grep -ho "${{inputs.regex}}") - echo "${temp_result}" - echo "${temp_result}" echo "new-tag=${temp_result}" >> $GITHUB_OUTPUT - name: update files