| # |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you 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: Test upgrade |
| |
| on: [push, pull_request] |
| |
| jobs: |
| populate-projects: |
| runs-on: ubuntu-latest |
| outputs: |
| projects_success: ${{ steps.set-matrix.outputs.projects_success }} |
| projects_fail: ${{ steps.set-matrix.outputs.projects_fail }} |
| steps: |
| - uses: actions/checkout@v3 |
| - id: set-matrix |
| shell: bash |
| run: | |
| echo "::set-output name=projects_success::$(ls .github/newt_upgrade/success/ | jq -R -s -c 'split("\n")[:-1]')" |
| echo "::set-output name=projects_fail::$(ls .github/newt_upgrade/fail/ | jq -R -s -c 'split("\n")[:-1]')" |
| |
| test_upgrade_success: |
| name: newt upgrade (success) |
| needs: populate-projects |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest, windows-latest, macos-latest] |
| projects: ${{ fromJson(needs.populate-projects.outputs.projects_success) }} |
| runs-on: ${{ matrix.os }} |
| steps: |
| - uses: actions/checkout@v3 |
| - uses: actions/setup-go@v3 |
| with: |
| go-version: 'stable' |
| - name: Build newt |
| working-directory: newt |
| shell: bash |
| run: | |
| go version |
| go build |
| echo ${GITHUB_WORKSPACE}/newt >> $GITHUB_PATH |
| git config --global url."https://github.com/".insteadOf "git@github.com:" |
| - name: Test upgrade success |
| shell: bash |
| working-directory: .github/newt_upgrade/success/${{ matrix.projects }} |
| run: | |
| echo "Checking target ${{ matrix.targets }}" |
| echo "Test initial install" |
| newt upgrade |
| newt info | grep mynewt-dummy | diff -w expected.txt - |
| echo "Checking out repos to origin/master" |
| for repo in `ls repos`; do git -C repos/"$repo" checkout -q origin/master; done |
| echo "Test upgrade" |
| newt upgrade |
| newt info | grep mynewt-dummy | diff -w expected.txt - |
| |
| test_upgrade_fail: |
| name: newt upgrade (fail) |
| needs: populate-projects |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest, windows-latest, macos-latest] |
| projects: ${{ fromJson(needs.populate-projects.outputs.projects_fail) }} |
| runs-on: ${{ matrix.os }} |
| steps: |
| - uses: actions/checkout@v3 |
| - uses: actions/setup-go@v3 |
| with: |
| go-version: 'stable' |
| - name: Build newt |
| working-directory: newt |
| shell: bash |
| run: | |
| go version |
| go build |
| echo ${GITHUB_WORKSPACE}/newt >> $GITHUB_PATH |
| git config --global url."https://github.com/".insteadOf "git@github.com:" |
| - name: Test upgrade fail |
| shell: bash |
| working-directory: .github/newt_upgrade/fail/${{ matrix.projects }} |
| run: | |
| echo "Checking target ${{ matrix.targets }}" |
| ! newt upgrade &> tmp.txt |
| cat tmp.txt | tail -n `wc -l < expected.txt` | diff -w expected.txt - |
| |
| test_upgrade_filters: |
| name: newt upgrade (filters) |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest, windows-latest, macos-latest] |
| runs-on: ${{ matrix.os }} |
| steps: |
| - uses: actions/checkout@v3 |
| - uses: actions/setup-go@v3 |
| with: |
| go-version: 'stable' |
| - name: Build newt |
| working-directory: newt |
| shell: bash |
| run: | |
| go version |
| go build |
| echo ${GITHUB_WORKSPACE}/newt >> $GITHUB_PATH |
| git config --global url."https://github.com/".insteadOf "git@github.com:" |
| - name: Test upgrade allowed-ignored |
| shell: bash |
| working-directory: .github/newt_upgrade/allowed-ignored |
| run: | |
| echo "Test upgrade" |
| newt upgrade |
| ls -1 repos | diff -w expected.txt - |