Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* senzing-factory/build-resources#69 add linting

* senzing-factory/build-resources#69 add linting

* update linting errors

* update linting errors

* test linting changes

* add missing workflow

* fix membership test
  • Loading branch information
kernelsam authored Feb 23, 2024
1 parent 48dbfd0 commit 10a7e14
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 86 deletions.
1 change: 1 addition & 0 deletions .github/linters/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
failure-threshold: error
3 changes: 3 additions & 0 deletions .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"line-length": false
}
2 changes: 1 addition & 1 deletion .github/workflows/add-labels-standardized.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'add labels standardized'
name: add labels standardized

on:
issues:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/add-to-project-factory-dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: 'add to project factory dependabot'
name: add to project factory dependabot

on:
pull_request:
branches: [main]

jobs:

add-issue-labels:
add-to-project-dependabot:
secrets:
SENZING_GITHUB_PROJECT_RW_TOKEN: ${{ secrets.SENZING_GITHUB_PROJECT_RW_TOKEN }}
uses: senzing-factory/build-resources/.github/workflows/add-to-project-dependabot.yaml@main
uses: senzing-factory/build-resources/.github/workflows/add-to-project-dependabot.yaml@v1
with:
project: ${{ vars.SENZING_PROJECT_FACTORY }}
9 changes: 5 additions & 4 deletions .github/workflows/add-to-project-factory.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'add to project factory'
name: add to project factory

on:
issues:
Expand All @@ -8,11 +8,12 @@ on:

jobs:
add-to-project:
name: Add issue to project
name: add issue to project
runs-on: ubuntu-latest

steps:
- name: Assign issue to project
- name: assign issue to project
uses: actions/add-to-project@v0.5.0
with:
project-url: https://github.com/orgs/${{ vars.SENZING_GITHUB_ACCOUNT_NAME }}/projects/${{ vars.SENZING_PROJECT_FACTORY }}
github-token: ${{ secrets.SENZING_GITHUB_ACCESS_TOKEN }}
project-url: https://github.com/orgs/${{ vars.SENZING_GITHUB_ACCOUNT_NAME }}/projects/${{ vars.SENZING_PROJECT_FACTORY }}
35 changes: 18 additions & 17 deletions .github/workflows/build-docker-container.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: build-docker-container.yaml
on:
pull_request:
branches:
- main
workflow_dispatch:
name: docker build container

on: [push]

jobs:
buildDockerContainer:
name: Build Docker container
docker-build-container:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: get repo name
id: repo-basename
run: |
echo "repo=$(basename ${{ github.repository }})" >> "$GITHUB_OUTPUT"
shell: bash

- name: build docker image
uses: senzing-factory/github-action-docker-buildx-build@v1
with:
fetch-depth: '0'
- name: Print environment variables
run: printenv
- name: Git Merge With Main
run: git merge origin/main
- name: Build Docker container
run: make docker-build
image-repository: senzing-factory/${{ steps.repo-basename.outputs.repo }}
image-tag: ${{ github.ref_name }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
14 changes: 14 additions & 0 deletions .github/workflows/dependabot-approve-and-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: dependabot approve and merge

on:
pull_request:
branches: [main]

jobs:
dependabot-approve-and-merge:
permissions:
contents: write
pull-requests: write
secrets:
SENZING_GITHUB_CODEOWNER_PR_RW_TOKEN: ${{ secrets.SENZING_GITHUB_CODEOWNER_PR_RW_TOKEN }}
uses: senzing-factory/build-resources/.github/workflows/dependabot-approve-and-merge.yaml@v1
11 changes: 11 additions & 0 deletions .github/workflows/lint-repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: lint repo

on:
push:
branches-ignore: [main]
pull_request:
branches: [main]

jobs:
lint-code-base:
uses: senzing-factory/build-resources/.github/workflows/linter.yaml@v1
14 changes: 14 additions & 0 deletions .github/workflows/move-pr-to-done-dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: move pr to done dependabot

on:
pull_request:
branches: [main]
types: [closed]

jobs:
move-pr-to-done-dependabot:
secrets:
SENZING_GITHUB_PROJECT_RW_TOKEN: ${{ secrets.SENZING_GITHUB_PROJECT_RW_TOKEN }}
uses: senzing-factory/build-resources/.github/workflows/move-pr-to-done-dependabot.yaml@v1
with:
project: ${{ vars.SENZING_PROJECT_FACTORY }}
23 changes: 0 additions & 23 deletions .github/workflows/pylint.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Project maintainers have the right and responsibility to remove, edit, or reject

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# github-action-identify-customer
# github-action-identify-customer
2 changes: 1 addition & 1 deletion docs/errors.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## Errors
# Errors
80 changes: 46 additions & 34 deletions send-to-slack.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,66 @@
#! /usr/bin/env python3

import urllib
import slack
import os
import json
import os
import urllib.request

import slack

slack_bearer_token = os.getenv('TOKEN')
repo = os.getenv('REPO_URL')
issue_number = os.getenv('NUMBER')
maker = os.getenv('CREATOR')
title = os.getenv('TITLE')
slack_string = os.getenv('SLACK_HASHES')
slack_bearer_token = os.getenv("TOKEN")
repo = os.getenv("REPO_URL")
issue_number = os.getenv("NUMBER")
maker = os.getenv("CREATOR")
title = os.getenv("TITLE")
slack_string = os.getenv("SLACK_HASHES")
slack_channel = "community-notifications"
repo_url = "https://github.com/" +repo
issue = "https://github.com/" +repo + "/issues/" + issue_number
user_url = "https://github.com/" + maker
repo_url = "https://github.com/{}".format(repo)
issue = "https://github.com/{}/issues/{}".format(repo, issue_number)
user_url = "https://github.com/{}".format(maker)
result = []

codeowners_url = "https://raw.githubusercontent.com/" + repo + "/main/.github/CODEOWNERS"
codeowners_url = "https://raw.githubusercontent.com/{}/main/.github/CODEOWNERS".format(
repo
)
try:
codeowners = urllib.request.urlopen(codeowners_url)
except:
codeowners_url = "https://raw.githubusercontent.com/" + repo + "/main/.github/CODEOWNERS"
codeowners = urllib.request.urlopen(codeowners_url)
codeowners = urllib.request.urlopen(codeowners_url)
except BaseException:
codeowners_url = (
"https://raw.githubusercontent.com/{}/main/.github/CODEOWNERS".format(repo)
)
codeowners = urllib.request.urlopen(codeowners_url)

SENZING_GITHUB_SLACK_MAP = json.loads(slack_string)
SENZING_GITHUB_SLACK_MAP = json.loads(str(slack_string))

codeowners = urllib.request.urlopen(codeowners_url)

for line in codeowners:
decoded_line = line.decode('utf-8')
uncommented_line = decoded_line.split("#")[0]
split_line = uncommented_line.split()
for split in split_line:
key = split.replace("@","")
if key in SENZING_GITHUB_SLACK_MAP.keys():
values = SENZING_GITHUB_SLACK_MAP.get(key)
if type(values) != list:
values = [values]
for value in values:
if not value in result:
result.append(value)

slack_message = "Customer created GitHub issue:\n*Repository:* <" + repo_url + "|" + repo + ">\n *Customer*: <" + user_url + "|" + maker + ">\n *Issue:* <" + issue + "|" + title + ">\n *Attention*: "
decoded_line = line.decode("utf-8")
uncommented_line = decoded_line.split("#")[0]
split_line = uncommented_line.split()
for split in split_line:
key = split.replace("@", "")
if key in SENZING_GITHUB_SLACK_MAP.keys():
values = SENZING_GITHUB_SLACK_MAP.get(key)
if type(values) != list:
values = [values]
for value in values:
if value not in result:
result.append(value)

slack_message = (
"Customer created GitHub issue:\n*Repository:* <"
"{0}|{1}>\n *Customer*: <"
"{2}|{3}>\n *Issue:* <"
"{4}|{5}>\n *Attention*: ".format(
repo_url, repo, user_url, maker, issue, title
)
)

for value in result:
slack_message = slack_message + "<@" + value + ">"

# Create a client that communicates with Slack.

slack_client = slack.WebClient(token=slack_bearer_token)

response = slack_client.chat_postMessage( channel=slack_channel, text=slack_message )
response = slack_client.chat_postMessage(channel=slack_channel, text=slack_message)

0 comments on commit 10a7e14

Please sign in to comment.