feat(lint): add changie validation job to lint action #288
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: lint | |
on: | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
workflow_call: | |
# concurrency: | |
# group: ${{ github.workflow }}-${{ github.ref }}-${{ github.action }} | |
# cancel-in-progress: false | |
permissions: | |
pull-requests: read | |
contents: read | |
checks: write | |
jobs: | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
checks: write # For trunk to post annotations | |
contents: read # For repo checkout | |
steps: | |
- name: checkout | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 | |
- name: set-aqua-policy-if-file-exists | |
run: | | |
if [[ -f aqua-policy.yaml ]]; then | |
echo "AQUA_POLICY_CONFIG=${GITHUB_WORKSPACE}/aqua-policy.yaml:${AQUA_POLICY_CONFIG}" >> $GITHUB_ENV | |
else | |
echo "👉 No aqua-policy.yaml file found, skipping setting AQUA_POLICY_CONFIG" | |
fi | |
- uses: aquaproj/aqua-installer@fd2089d1f56724d6456f24d58605e6964deae124 # v2.3.2 | |
continue-on-error: true | |
with: | |
aqua_version: v2.30.0 | |
enable_aqua_install: true | |
aqua_opts: '--tags lint' # if using aqua.yaml config any special items in your repo like Golangci-lint using tags so it only installs what's needed | |
env: | |
AQUA_LOG_LEVEL: debug | |
AQUA_OPTS: '' | |
- name: trunk-check | |
uses: trunk-io/trunk-action@86b68ffae610a05105e90b1f52ad8c549ef482c2 # v1.1.16 | |
with: | |
arguments: --github-annotate-new-only=true | |
changie-validation: | |
name: changie-validation | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ github.token }} | |
steps: | |
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 | |
- name: Check for .changes directory | |
id: check_changes_dir | |
run: | | |
if [[ -d ".changes" ]]; then | |
echo "changes_dir_exists=true" >> $GITHUB_OUTPUT | |
else | |
echo "changes_dir_exists=false" >> $GITHUB_OUTPUT | |
echo "⏩ no changie entry required on this" | |
fi | |
- name: Check for labels | |
id: check_labels | |
run: | | |
echo "no_changie_required=false" >> $GITHUB_OUTPUT | |
echo "dependencies=false" >> $GITHUB_OUTPUT | |
for label in $(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name'); do | |
if [[ "$label" == "no-changie-required" ]]; then | |
echo "no_changie_required=true" >> $GITHUB_OUTPUT | |
echo "❎ bypass on changie noted due to label" | |
elif [[ "$label" == "dependencies" ]]; then | |
echo "dependencies=true" >> $GITHUB_OUTPUT | |
fi | |
done | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Validate changie entry | |
id: validate_changie_entry | |
if: steps.check_changes_dir.outputs.changes_dir_exists == 'true' && steps.check_labels.outputs.no_changie_required == 'false' && steps.check_labels.outputs.dependencies == 'false' | |
run: | | |
if [[ -z "$(ls -A .changes/unreleased)" ]]; then | |
echo "No changie entry found in .changes/unreleased" | |
comment="❌ A changie entry is required in .changes/unreleased" | |
else | |
echo "Changie entry found" | |
comment="✅ showing changie entry was found" | |
fi | |
if [[ -n "$comment" ]]; then | |
gh pr comment ${{ github.event.pull_request.number }} --body "$comment" --edit-last | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |