diff --git a/.github/workflows/pr_actions.yml b/.github/workflows/pr_actions.yml new file mode 100644 index 0000000000000..09b54659bc566 --- /dev/null +++ b/.github/workflows/pr_actions.yml @@ -0,0 +1,72 @@ +# This file contains actions that can be performed on PRs by issuing a comment +name: 🕹️ On demand PR action + +on: + issue_comment: + types: [created, edited] + +jobs: + # Action to update test results by issuing /lint + run_lint: + name: "On demand linting" + if: ${{ github.event.issue.pull_request }} && github.event.comment.body == '/lint' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + # grab the PR branch + ref: ${{ github.event.pull_request.head.ref }} + # We can't use GITHUB_TOKEN here because, github actions can't trigger actions + # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow + # So this is a personal access token + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + # we need origin/main to have comparison linting work ! + - name: Fetch origin/main + run: git fetch origin main --depth=1 + - name: Run linting + run: make lint front_lint + - name: Push changes if needed + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "chore: Linting changes" + branch: ${{ github.event.pull_request.head.ref }} + commit_user_name: Open Food Facts Bot + commit_user_email: contact@openfoodfacts.org + commit_author: Open Food Facts Bot + push_options: "" + status_options: '--untracked-files=no' + skip_dirty_check: false + create_branch: no + + # Action to update test results by issuing /update_tests_results + update_test_results: + name: "On demand Update Tests Results" + if: ${{ github.event.issue.pull_request }} && github.event.comment.body == '/update_tests_results' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + # grab the PR branch + ref: ${{ github.event.pull_request.head.ref }} + # We can't use GITHUB_TOKEN here because, github actions can't trigger actions + # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow + # So this is a personal access token + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + - name: Run update tests results + run: make update_tests_results + - name: Push changes if needed + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "test: Update tests results" + branch: ${{ github.event.pull_request.head.ref }} + commit_user_name: Open Food Facts Bot + commit_user_email: contact@openfoodfacts.org + commit_author: Open Food Facts Bot + push_options: "" + status_options: '--untracked-files=no' + skip_dirty_check: false + create_branch: no \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 036ec66d7f9d0..044161017c347 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -56,6 +56,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + # needs depth to run git log below fetch-depth: 50 - name: build run: make build container=backend @@ -78,7 +79,10 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 50 + fetch-depth: 1 + # we need origin/main to have comparison linting work ! + - name: Fetch origin/main + run: git fetch origin main --depth=1 - name: Download backend image from artifacts uses: ishworkh/docker-image-artifact-download@v1 with: @@ -101,7 +105,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 50 + fetch-depth: 1 - name: Download backend image from artifacts uses: ishworkh/docker-image-artifact-download@v1 with: @@ -129,7 +133,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 50 + fetch-depth: 1 - name: Download backend image from artifacts uses: ishworkh/docker-image-artifact-download@v1 with: diff --git a/Makefile b/Makefile index 89d027ae53c81..991b3b5f9c383 100644 --- a/Makefile +++ b/Makefile @@ -495,8 +495,10 @@ clone_deps: for dep in ${DEPS} ; do \ echo $$dep; \ if [ ! -d ${DEPS_DIR}/$$dep ]; then \ + echo "Cloning $$dep"; \ git clone --filter=blob:none --sparse \ https://github.com/openfoodfacts/$$dep.git ${DEPS_DIR}/$$dep; \ + echo "Cloned $$dep"; \ else \ cd ${DEPS_DIR}/$$dep && git pull; \ fi; \