<commit_before># Copyright 2020 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Update Nightlies

on:
  schedule:
  - cron: '0 11 * * 1-5' # 4am Pacific on weekdays

  workflow_dispatch:

jobs:

  update-nightlies:
    name: update nightlies
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false # Keep running if one leg fails.
      matrix:
        nightly:
        - net-certmanager
        - net-contour
        - net-istio
        - net-kourier
        - net-gateway-api
        - eventing-kafka-broker-eventing-kafka
        - eventing-kafka-broker-eventing
        - eventing-rabbitmq-eventing

        # Map to nightly-specific parameters.
        include:
        - nightly: net-certmanager
          module: knative.dev/net-certmanager
          directory: ./third_party/cert-manager-latest
          files: net-certmanager.yaml
          bucket: net-certmanager
          repository: knative/serving
          fork: serving
          channel: net-certmanager
          assignee: "@knative/networking-wg-leads"
        - nightly: net-contour
          module: knative.dev/net-contour
          directory: ./third_party/contour-latest
          files: net-contour.yaml contour.yaml
          bucket: net-contour
          repository: knative/serving
          fork: serving
          channel: net-contour
          assignee: "@knative/networking-wg-leads"
        - nightly: net-istio
          module: knative.dev/net-istio
          directory: ./third_party/istio-latest
          files: net-istio.yaml
          bucket: net-istio
          repository: knative/serving
          fork: serving
          channel: net-istio
          assignee: "@knative/networking-wg-leads"
        - nightly: net-kourier
          module: knative.dev/net-kourier
          directory: ./third_party/kourier-latest
          files: kourier.yaml
          bucket: net-kourier
          repository: knative/serving
          fork: serving
          channel: net-kourier
          assignee: "@knative/networking-wg-leads"
        - nightly: net-gateway-api
          module: knative.dev/net-gateway-api
          directory: ./third_party/gateway-api-latest
          files: net-gateway-api.yaml istio-gateway.yaml
          bucket: net-gateway-api
          repository: knative/serving
          fork: serving
          channel: net-gateway-api
          assignee: "@knative/networking-wg-leads"
        - nightly: eventing-kafka-broker-eventing
          module: knative.dev/eventing-kafka-broker
          directory: ./third_party/eventing-latest
          files: eventing-crds.yaml eventing-core.yaml
          bucket: eventing
          repository: knative-sandbox/eventing-kafka-broker
          fork: eventing-kafka-broker
          channel: eventing-delivery
          assignee: "@knative/delivery-wg-leads"
        - nightly: eventing-kafka-broker-eventing-kafka
          module: knative.dev/eventing-kafka-broker
          directory: ./third_party/eventing-kafka-latest
          files: channel-crds.yaml source-crd.yaml
          bucket: eventing-kafka
          repository: knative-sandbox/eventing-kafka-broker
          fork: eventing-kafka-broker
          channel: eventing-delivery
          assignee: "@knative/delivery-wg-leads"
        - nightly: eventing-rabbitmq-eventing
          module: knative.dev/eventing-rabbitmq
          directory: ./third_party/eventing-latest
          files: eventing-crds.yaml eventing-core.yaml
          bucket: eventing
          repository: knative-sandbox/eventing-rabbitmq
          fork: eventing-rabbitmq
          channel: eventing-delivery
          assignee: "@knative-sandbox/eventing-rabbitmq-approvers"

    steps:
    - name: Set up Go 1.17.x
      uses: actions/setup-go@v2
      with:
        go-version: 1.17.x

    - name: Install Dependencies
      run: |
        go install github.com/dprotaso/modlog@latest

    - name: Check out code onto GOPATH
      uses: actions/checkout@v2
      with:
        repository: ${{ matrix.repository }}

    - name: Download nightlies
      shell: bash
      id: nightlies
      run: |
        for x in ${{ matrix.files }}; do
          curl https://storage.googleapis.com/knative-nightly/${{ matrix.bucket }}/latest/$x > ${GITHUB_WORKSPACE}/${{ matrix.directory }}/$x
        done

        function release_labels() {
          # If grep matches no lines (exit code == 1) make this a noop since pipefail is on
          git diff | { grep -E 'knative.dev/release.?:' || [[ $? == 1 ]]; } | tr -s ' '
        }

        # Prior to the 'sed' we have output in the following format:
        #
        # - serving.knative.dev/release: "v20210111-9f0302e4"
        # + serving.knative.dev/release: "v20210112-9f0302e4"
        #
        ref_count=$(release_labels | sed 's/.* "\(.*\)"$/\1/' | cut -d '-' -f2 | sort -u | wc -l)

        if [[ "$ref_count" -lt 2 ]]; then
          # For debugging
          release_labels | sort -u
          echo "::warning file=.github.js,line=1::${{matrix.nightly}} -  skipping bump no changes"
          exit 0
        fi

        echo "create_pr=true" >> $GITHUB_ENV

        from_sha=$(release_labels | sort -u  | sed 's/^\([+-]\).* ".*-\(.*\)"$/\1 \2/' | grep '-' | cut -d ' ' -f2)
        to_sha=$(release_labels | sort -u  | sed 's/^\([+-]\).* ".*-\(.*\)"$/\1 \2/' | grep '+' | cut -d ' ' -f2)

        if [[ -z "$from_sha" ]]  || [[ -z "$to_sha" ]]; then<commit_msg>fix nightly releases that use app.kubernetes.io/version annotation (#169)<commit_after># Copyright 2020 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Update Nightlies

on:
  schedule:
  - cron: '0 11 * * 1-5' # 4am Pacific on weekdays

  workflow_dispatch:

jobs:

  update-nightlies:
    name: update nightlies
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false # Keep running if one leg fails.
      matrix:
        nightly:
        - net-certmanager
        - net-contour
        - net-istio
        - net-kourier
        - net-gateway-api
        - eventing-kafka-broker-eventing-kafka
        - eventing-kafka-broker-eventing
        - eventing-rabbitmq-eventing

        # Map to nightly-specific parameters.
        include:
        - nightly: net-certmanager
          module: knative.dev/net-certmanager
          directory: ./third_party/cert-manager-latest
          files: net-certmanager.yaml
          bucket: net-certmanager
          repository: knative/serving
          fork: serving
          channel: net-certmanager
          assignee: "@knative/networking-wg-leads"
        - nightly: net-contour
          module: knative.dev/net-contour
          directory: ./third_party/contour-latest
          files: net-contour.yaml contour.yaml
          bucket: net-contour
          repository: knative/serving
          fork: serving
          channel: net-contour
          assignee: "@knative/networking-wg-leads"
        - nightly: net-istio
          module: knative.dev/net-istio
          directory: ./third_party/istio-latest
          files: net-istio.yaml
          bucket: net-istio
          repository: knative/serving
          fork: serving
          channel: net-istio
          assignee: "@knative/networking-wg-leads"
        - nightly: net-kourier
          module: knative.dev/net-kourier
          directory: ./third_party/kourier-latest
          files: kourier.yaml
          bucket: net-kourier
          repository: knative/serving
          fork: serving
          channel: net-kourier
          assignee: "@knative/networking-wg-leads"
        - nightly: net-gateway-api
          module: knative.dev/net-gateway-api
          directory: ./third_party/gateway-api-latest
          files: net-gateway-api.yaml istio-gateway.yaml
          bucket: net-gateway-api
          repository: knative/serving
          fork: serving
          channel: net-gateway-api
          assignee: "@knative/networking-wg-leads"
        - nightly: eventing-kafka-broker-eventing
          module: knative.dev/eventing-kafka-broker
          directory: ./third_party/eventing-latest
          files: eventing-crds.yaml eventing-core.yaml
          bucket: eventing
          repository: knative-sandbox/eventing-kafka-broker
          fork: eventing-kafka-broker
          channel: eventing-delivery
          assignee: "@knative/delivery-wg-leads"
        - nightly: eventing-kafka-broker-eventing-kafka
          module: knative.dev/eventing-kafka-broker
          directory: ./third_party/eventing-kafka-latest
          files: channel-crds.yaml source-crd.yaml
          bucket: eventing-kafka
          repository: knative-sandbox/eventing-kafka-broker
          fork: eventing-kafka-broker
          channel: eventing-delivery
          assignee: "@knative/delivery-wg-leads"
        - nightly: eventing-rabbitmq-eventing
          module: knative.dev/eventing-rabbitmq
          directory: ./third_party/eventing-latest
          files: eventing-crds.yaml eventing-core.yaml
          bucket: eventing
          repository: knative-sandbox/eventing-rabbitmq
          fork: eventing-rabbitmq
          channel: eventing-delivery
          assignee: "@knative-sandbox/eventing-rabbitmq-approvers"

    steps:
    - name: Set up Go 1.17.x
      uses: actions/setup-go@v2
      with:
        go-version: 1.17.x

    - name: Install Dependencies
      run: |
        go install github.com/dprotaso/modlog@latest

    - name: Check out code onto GOPATH
      uses: actions/checkout@v2
      with:
        repository: ${{ matrix.repository }}

    - name: Download nightlies
      shell: bash
      id: nightlies
      run: |
        for x in ${{ matrix.files }}; do
          curl https://storage.googleapis.com/knative-nightly/${{ matrix.bucket }}/latest/$x > ${GITHUB_WORKSPACE}/${{ matrix.directory }}/$x
        done

        function release_labels() {
          # If grep matches no lines (exit code == 1) make this a noop since pipefail is on
          git diff | { grep -E 'knative.dev/release.?:|app.kubernetes.io/version:' || [[ $? == 1 ]]; } | tr -s ' '
        }

        # Prior to the 'sed' we have output in the following format:
        #
        # - serving.knative.dev/release: "v20210111-9f0302e4"
        # + serving.knative.dev/release: "v20210112-9f0302e4"
        #
        # or
        #
        # - app.kubernetes.io/version: "v20210111-9f0302e4"
        # + app.kubernetes.io/version: "v20210112-9f0302e4"
        #
        ref_count=$(release_labels | sed 's/.* "\(.*\)"$/\1/' | cut -d '-' -f2 | sort -u | wc -l)

        if [[ "$ref_count" -lt 2 ]]; then
          # For debugging
          release_labels | sort -u
          echo "::warning file=.github.js,line=1::${{matrix.nightly}} -  skipping bump no changes"
          exit 0
        fi

        echo "create_pr=true" >> $GITHUB_ENV

        from_sha=$(release_labels | sort -u  | sed 's/^\([+-]\).* ".*-\(.*\)"$/\1 \2/' | grep '-' | cut -d ' ' -f2 | sort -u)
        to_sha=$(release_labels | sort -u  | sed 's/^\([+-]\).* ".*-\(.*\)"$/\1 \2/' | grep '+' | cut -d ' ' -f2 | sort -u)

        if [[ -z "$from_sha" ]]  || [[ -z "$to_sha" ]]; then
{'fraction_non_alphanumeric': 0.11477572559366754, 'fraction_numerical': 0.012945250659630607, 'mean_word_length': 1.9970348406226834, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '961094', 'n_tokens_mistral': 3905, 'n_tokens_neox': 3683, 'n_words': 877}