Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #238 from comigor/beta
Browse files Browse the repository at this point in the history
Promote 6.17.1-beta.1 to master
  • Loading branch information
comigor authored Nov 18, 2020
2 parents 119ea63 + e789131 commit 1248544
Show file tree
Hide file tree
Showing 115 changed files with 12,302 additions and 2,695 deletions.
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ assignees: ''

---

**Bug description**
**Before reporting a bug, please test the beta branch!**

## Bug description
Please describe what happened wrong and the expected behaviour/output.

**Specs**
## Specs
Artemis version: [e.g. 6.0.3-beta.1]
<details>
<summary>build.yaml:</summary>
Expand Down
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Make sure you're opening this pull request pointing to beta branch!**

## What does this PR do/solve?
9 changes: 9 additions & 0 deletions .github/actions/check-version-and-changelog/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM makocchi/alpine-git-curl-jq

ENV OQ_VERSION 1.1.0
RUN curl -L https://github.com/Blacksmoke16/oq/releases/download/v${OQ_VERSION}/oq-v${OQ_VERSION}-linux-x86_64 > /usr/local/bin/oq \
&& chmod +x /usr/local/bin/oq

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
20 changes: 20 additions & 0 deletions .github/actions/check-version-and-changelog/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Check version and changelog"
description: "Make sure the version is bumped and it has a changelog entry"
inputs:
repo_token:
description: "Access token for sending errors as a PR message"
required: false
default: ""
base_ref:
description: "GitHub base_ref"
required: true
default: ""
outputs:
package_version:
description: "The package version"
runs:
using: "docker"
image: "Dockerfile"
args:
- "${{ inputs.repo_token }}"
- "${{ inputs.base_ref }}"
65 changes: 65 additions & 0 deletions .github/actions/check-version-and-changelog/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/ash

cd "$GITHUB_WORKSPACE"

REPO_TOKEN="$1"
github_ref="$2"

PR_HREF=$(cat "$GITHUB_EVENT_PATH" | jq -r '.pull_request._links.self.href')

function send_message_and_bail {
ERROR="$1"

if [ ! -z "$REPO_TOKEN" ]; then
jq -c -n --arg body "$ERROR" '{"event":"COMMENT", "body":$body}' > /tmp/payload.json
curl -f -X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $REPO_TOKEN" \
--data "@/tmp/payload.json" \
"$PR_HREF/reviews" -vv || true
fi

echo "------------------------------------------------"
echo "$ERROR"
echo "------------------------------------------------"
exit 1
}

# echo "PARAM GITHUB REF: $github_ref"
# echo "GITHUB EVENT NAME: $GITHUB_EVENT_NAME"
# echo "GITHUB REF: $GITHUB_REF"
# echo "GITHUB BASE REF: $GITHUB_BASE_REF"
# echo "GITHUB HEAD REF: $GITHUB_HEAD_REF"

git fetch --prune --unshallow

if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
where="origin/$github_ref"
else
where=HEAD~$(jq '.commits | length' "${GITHUB_EVENT_PATH}")
fi

diff=$(git diff $where pubspec.yaml)

echo "$diff" | grep -E '\+.*version' || {
send_message_and_bail "You must bump the version on pubspec!"
}

package_version=$(cat pubspec.yaml | oq -i YAML -r '.version')

# If are on master or beta
if [ "$github_ref" = "master" ] || [ "$github_ref" = "refs/heads/master" ]; then
echo "$package_version" | grep "beta" && {
send_message_and_bail "You can't merge a \"beta\" version on \`master\` branch!"
}
elif [ "$github_ref" = "beta" ] || [ "$github_ref" = "refs/heads/beta" ]; then
echo "$package_version" | grep "beta" || {
send_message_and_bail "You can only merge a \"beta\" version on \`beta\` branch!"
}
fi

cat CHANGELOG.md | grep -q "$package_version" || {
send_message_and_bail "Version \`$package_version\` not found on CHANGELOG!"
}

echo "::set-output name=package_version::$package_version"
8 changes: 8 additions & 0 deletions .github/actions/dart-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM cirrusci/flutter

USER root

RUN apt update && apt install -y jq

ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
36 changes: 36 additions & 0 deletions .github/actions/dart-test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Run linter and tests on a Dart package"
description: "Run linter and tests on a Dart package"
inputs:
repo_token:
description: "Access token for sending errors as a PR message"
required: false
is_flutter:
description: "Run everything on Flutter context instead of Dart's"
required: false
default: "false"
disable_linter:
description: "Disable dry-run dartfmt linter check"
required: false
default: "false"
disable_analyzer:
description: "Disable dartanalyzer"
required: false
default: "false"
disable_tests:
description: "Disable pub run test"
required: false
default: "false"
exclude_regex:
description: "Regex to be used to exclude folders when looking for pubspec.yaml files"
required: false
default: "__________________"
runs:
using: "docker"
image: "Dockerfile"
args:
- "${{ inputs.repo_token }}"
- "${{ inputs.is_flutter }}"
- "${{ inputs.disable_linter }}"
- "${{ inputs.disable_analyzer }}"
- "${{ inputs.disable_tests }}"
- "${{ inputs.exclude_regex }}"
91 changes: 91 additions & 0 deletions .github/actions/dart-test/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

set -eu

REPO_TOKEN="$1"
DTA_IS_FLUTTER="$2"
DTA_DISABLE_LINTER="$3"
DTA_DISABLE_ANALYZER="$4"
DTA_DISABLE_TESTS="$5"
DTA_EXCLUDE_REGEX="$6"

echo "DTA_IS_FLUTTER=$DTA_IS_FLUTTER"
echo "DTA_DISABLE_LINTER=$DTA_DISABLE_LINTER"
echo "DTA_DISABLE_ANALYZER=$DTA_DISABLE_ANALYZER"
echo "DTA_DISABLE_TESTS=$DTA_DISABLE_TESTS"
echo "DTA_EXCLUDE_REGEX=$DTA_EXCLUDE_REGEX"

cd "$GITHUB_WORKSPACE"

PR_HREF=$(cat "$GITHUB_EVENT_PATH" | jq -r '.pull_request._links.self.href')

function send_message_and_bail {
ERROR="$1"
DETAIL="$2"

if [ ! -z "$REPO_TOKEN" ]; then
BODY=$(cat <<EOF
$ERROR
<details>
<pre>
$DETAIL
</pre>
</details>
EOF
)

jq -c -n --arg body "$BODY" '{"event":"COMMENT", "body":$body}' > /tmp/payload.json
curl -f -X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $REPO_TOKEN" \
--data "@/tmp/payload.json" \
"$PR_HREF/reviews" -vv || true
fi

echo "------------------------------------------------"
echo "$ERROR"
echo "$DETAIL"
echo "------------------------------------------------"
exit 1
}

for ppath in $(find . -name pubspec.yaml | grep -ve "$DTA_EXCLUDE_REGEX"); do
echo "=== On $ppath ==="
cd $(dirname "$ppath");

echo "=== Downloading dependencies ==="
if [ "$DTA_IS_FLUTTER" = "false" ]; then
pub get
else
flutter pub get
fi

if [ "$DTA_DISABLE_LINTER" = "false" ]; then
echo "=== Running linter ==="
OUTPUT=$(dartfmt -n . --set-exit-if-changed 2>&1)

if [ $? -ne 0 ]; then
send_message_and_bail "Linter has failed!" "$OUTPUT"
fi
fi

if [ "$DTA_DISABLE_ANALYZER" = "false" ]; then
echo "=== Running analyzer ==="
OUTPUT=$(dartanalyzer --fatal-infos --fatal-warnings . 2>&1) || send_message_and_bail "Analyzer has failed!" "$OUTPUT"
fi

[ -d "test" ] && {
if [ "$DTA_DISABLE_TESTS" = "false" ]; then
echo "=== Running tests ==="
if [ "$DTA_IS_FLUTTER" = "false" ]; then
OUTPUT=$(pub run test --no-color -r expanded -- test/query_generator/aliases/alias_on_leaves_test.dart 2>&1) || send_message_and_bail "Tests failed!" "$OUTPUT"
else
OUTPUT=$(flutter test 2>&1) || send_message_and_bail "Tests failed!" "$OUTPUT"
fi
fi
}

# Go back
cd -
done
12 changes: 0 additions & 12 deletions .github/workflows/analyzer.yml

This file was deleted.

59 changes: 12 additions & 47 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,19 @@ on: pull_request
name: CI

jobs:
test:
check-version-and-changelog:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@master
- name: Run tests
uses: comigor/actions/dart-test@master
env:
DTA_EXCLUDE_REGEX: example
check-version-and-changelog:
needs: test
- uses: actions/checkout@master
- uses: ./.github/actions/check-version-and-changelog
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
base_ref: "${{ github.base_ref }}"
test:
runs-on: ubuntu-latest
container: golang
steps:
- uses: actions/checkout@master
- run: |
GO111MODULE=on go get -u github.com/itchyny/gojq/cmd/gojq@d24ecb5d89a9eee8b4cd2071bdff7585a8b44f0e
cd "$GITHUB_WORKSPACE"
- name: Check if version on pubspec.yaml was changed and if there's an entry for this new version on CHANGELOG
run: |
echo "GITHUB EVENT NAME: ${{ github.event_name }}"
echo "GITHUB REF: $GITHUB_REF"
echo "GITHUB REF: ${{ github.ref }}"
echo "GITHUB HEAD REF: ${{ github.head_ref }}"
echo "GITHUB BASE REF: ${{ github.base_ref }}"
git fetch --prune --unshallow
where="origin/${{ github.base_ref }}"
diff=$(git diff $where pubspec.yaml)
echo "$diff" | grep -E '\+.*version' || {
echo "Version not bumped on pubspec"
exit 1
}
package_version=$(cat pubspec.yaml | gojq --yaml-input -r '.version')
# If are on master or beta
if [ "${{ github.base_ref }}" = "master" ]; then
echo "$package_version" | grep beta && {
echo "Version cant contain beta"
exit 1
}
elif [ "${{ github.base_ref }}" = "beta" ]; then
echo "$package_version" | grep beta || {
echo "Missing beta on version"
exit 1
}
fi
cat CHANGELOG.md | grep "$package_version"
- uses: actions/checkout@master
- uses: ./.github/actions/dart-test
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
exclude_regex: "example"
52 changes: 52 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
push:
branches:
- master
- beta

name: CI

jobs:
test:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta'
steps:
- name: Clone repository
uses: actions/checkout@master
- name: Run tests
uses: comigor/actions/dart-test@master
env:
DTA_EXCLUDE_REGEX: example
create-tag-and-release:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta'
steps:
- uses: actions/checkout@master
- id: check_version_and_changelog
name: Check if version on pubspec.yaml was changed and if there's an entry for this new version on CHANGELOG
uses: ./.github/actions/check-version-and-changelog
with:
base_ref: "${{ github.ref }}"
- name: Push tag
uses: anothrNick/github-tag-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: "v${{ steps.check_version_and_changelog.outputs.package_version }}"
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ steps.check_version_and_changelog.outputs.package_version }}"
release_name: "Release v${{ steps.check_version_and_changelog.outputs.package_version }}"
deploy:
needs: create-tag-and-release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta'
steps:
- uses: actions/checkout@master
- name: Publish to pub.dev
uses: comigor/actions/pub-publish@master
env:
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }}
Loading

0 comments on commit 1248544

Please sign in to comment.