diff --git a/.github/workflows/test-maven-setup-action.yaml b/.github/workflows/test-maven-setup-action.yaml new file mode 100644 index 0000000..db8170d --- /dev/null +++ b/.github/workflows/test-maven-setup-action.yaml @@ -0,0 +1,84 @@ +name: test-maven-setup-action +on: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-16.04 + name: test maven-setup action + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1.3.0 + with: + java-version: '13' + - uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - run: env | sort + - uses: navikt/bidrag-maven/setup@main + with: + repositories: maven-releases=https://repo.releases,snapshots=https://repo.snapshots + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: mvn help:effective-pom + - name: Verify .m2 home + run: | + POM=$(cat ~/.m2/settings.xml) + echo $POM + echo count number of repos + COUNT_REPOS=$(echo $POM | grep -c https://repo) + + echo count number of maven-releases + COUNT_NAME_MAVEN=$(echo $POM | grep -c maven-releases) + + echo count number of snapshots + COUNT_NAME_SNAP=$(echo $POM | grep -c snapshots) + + echo count number of github actor + COUNT_ACTOR=$(echo $POM | grep -c $GITHUB_ACTOR) + + echo count number of github tokens + COUNT_TOKEN=$(echo $POM | grep -c $GITHUB_TOKEN) + + # FOR SOME REASON, ONLY COUNTS ONE???? + echo check number of repos + if [[ $COUNT_REPOS -ne 1 ]]; then + echo ::error:: $COUNT_REPOS is not expected 2 repositories urls from the settings.xml + exit 1 + fi + + # FOR SOME REASON, ONLY COUNTS ONE???? + echo check number of maven-releases + if [[ $COUNT_NAME_MAVEN -ne 1 ]]; then + echo ::error:: expected maven-releases to occur for server/repo id and repo name in the settings.xml, but found: $COUNT_NAME_MAVEN + exit 1 + fi + + # FOR SOME REASON, ONLY COUNTS ONE???? + echo check number of snapshots + if [[ $COUNT_NAME_SNAP -ne 1 ]]; then + echo ::error:: could not find name snapshots to occur for server/repo id and repo name in the settings.xml, but found: $COUNT_NAME_SNAP + exit 1 + fi + + # FOR SOME REASON, ONLY COUNTS ONE???? + echo check number of github actor + if [[ $COUNT_ACTOR -ne 1 ]]; then + echo ::error:: could not find github actor as username for each repository, but found: $COUNT_ACTOR + exit 1 + fi + + # FOR SOME REASON, ONLY COUNTS ONE???? + echo check number of github tokens + if [[ $COUNT_TOKEN -ne 1 ]]; then + echo ::error:: could not find github token as password for each repository, but found: $COUNT_TOKEN + exit 1 + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}