Skip to content

update CI helper and project structure #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions scripts/ci_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,40 @@

import click, git

class CIHelper():
""" Helper class for all CI/CD operations.
"""

DEFAULT_PROJECT_DIR = "web/code"
class CIHelper:
"""Helper class for all CI/CD operations."""

DEFAULT_PROJECT_DIR = "web/static/code"

def __init__(self):
""" Initialize enumerators. Determine which directories to test.
"""
"""Initialize enumerators. Determine which directories to test."""
self.project_dir = os.getenv("PROJECT_DIR", self.DEFAULT_PROJECT_DIR)
self.blacklisted = self._get_ignore_dirs()
self.ts_repo = os.getenv("REPO_ROOT_DIR", ".")

def _get_ignore_dirs(self):
""" Determine which directories to ignore.
"""
"""Determine which directories to ignore."""
blacklisted = os.getenv("BLACKLISTED_DIRS", "")
return [x.strip() for x in blacklisted.split(",")]

def get_pulumi_projects(self):
""" Get Pulumi project directories.
"""
"""Get Pulumi project directories."""
results = set()
changed_files = self._get_changed_files()
changed_paths = [ str(Path(x).parent) for x in changed_files]
for path in Path(self.project_dir).rglob('Pulumi.*.yaml'):
changed_paths = [str(Path(x).parent) for x in changed_files]
for path in Path(self.project_dir).rglob("Pulumi.*.yaml"):
path_str = str(path.parent)
if "node_modules" not in path_str and \
path_str not in self.blacklisted and \
path_str in changed_paths:
if (
"node_modules" not in path_str
and path_str not in self.blacklisted
and path_str in changed_paths
):
results.add(path_str)
return list(results)

def dir_changed(self, dir):
""" Determine if website has been updated
"""
"""Determine if website has been updated"""
result = False
changes = self._get_changed_files()
for change in changes:
Expand All @@ -51,35 +49,41 @@ def dir_changed(self, dir):
return result

def _get_changed_files(self):
""" Get list of files that changed in branch.
"""
"""Get list of files that changed in branch."""
repo = git.Repo(".", search_parent_directories=True)
changes = [ item.a_path for item in repo.index.diff("origin/main") ]
return(changes)
changes = [item.a_path for item in repo.index.diff("origin/main")]
return changes


@click.group()
def helper():
pass


@helper.group()
def web():
pass


@helper.group()
def code():
pass


@web.command("has-changed")
def changed_web():
click.echo(CIHelper().dir_changed("web/content"))


@code.command("has-changed")
def changed_code():
click.echo(CIHelper().dir_changed("web/code"))


@code.command("ls")
def list_pulumi():
click.echo(CIHelper().get_pulumi_projects())


if __name__ == "__main__":
helper()
26 changes: 13 additions & 13 deletions web/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ themesdir = "themes"
theme = "hugo-theme-relearn"

[params]
alwaysopen = false
editUrl = 'https://github.com/MichaelStott/tech-squawks/tree/main/web/content/'
showVisitedLinks = false
collapsibleMenu = true
disableBreadcrumb = false
disableInlineCopyToClipBoard = true
disableNextPrev = false
disableLandingPageButton = false
titleSeparator = "::"
themeVariant = [ "light", "dark" ]
alwaysopen = false
editUrl = 'https://github.com/MichaelStott/tech-squawks/tree/main/web/content/'
showVisitedLinks = false
collapsibleMenu = true
disableBreadcrumb = false
disableInlineCopyToClipBoard = true
disableNextPrev = false
disableLandingPageButton = false
titleSeparator = "::"
themeVariant = ["light", "dark"]

[[menu.shortcuts]]
name = "<i class='fab fa-fw fa-github'></i> Tech Squawks Repository"
Expand All @@ -29,6 +29,6 @@ url = "https://github.com/MichaelStott/tech-squawks/issues/new/choose"
weight = 20

[outputs]
home = ["HTML", "RSS", "PRINT", "SEARCH", "SEARCHPAGE"]
section = ["HTML", "RSS", "PRINT"]
page = ["HTML", "RSS", "PRINT"]
home = ["HTML", "RSS", "PRINT", "SEARCH", "SEARCHPAGE"]
section = ["HTML", "RSS", "PRINT"]
page = ["HTML", "RSS", "PRINT"]
16 changes: 8 additions & 8 deletions web/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pulumi destroy -y
{{% tab name="index.ts" %}}

```ts
{{% include file="code\homepage\ts\index.ts" %}}
{{% include file="assets\homepage\ts\index.ts" %}}
```

{{% /tab %}}
Expand Down Expand Up @@ -65,7 +65,7 @@ pulumi destroy -y
{{% tab name="index.js" %}}

```js
{{% include file="code\homepage\js\index.js" %}}
{{% include file="assets\homepage\js\index.js" %}}
```

{{% /tab %}}
Expand Down Expand Up @@ -95,21 +95,21 @@ pulumi destroy -y
{{% tab name="__main__.py" %}}

```py
{{% include file="code\homepage\py\__main__.py" %}}
{{% include file="assets\homepage\py\__main__.py" %}}
```

{{% /tab %}}
{{% tab name="lambda.py" %}}

```py
{{% include file="code\homepage\py\lambda.py" %}}
{{% include file="assets\homepage\py\lambda.py" %}}
```

{{% /tab %}}
{{% tab name="lambda_util.py" %}}

```py
{{% include file="code\homepage\py\lambda_util.py" %}}
{{% include file="assets\homepage\py\lambda_util.py" %}}
```

{{% /tab %}}
Expand Down Expand Up @@ -139,21 +139,21 @@ pulumi destroy -y
{{% tab name="main.go" %}}

```go
{{% include file="code\homepage\go\main.go" %}}
{{% include file="assets\homepage\go\main.go" %}}
```

{{% /tab %}}
{{% tab name="handler.go" %}}

```go
{{% include file="code\homepage\go\handler\handler.go" %}}
{{% include file="assets\homepage\go\handler\handler.go" %}}
```

{{% /tab %}}
{{% tab name="lambda_util.go" %}}

```go
{{% include file="code\homepage\go\lambda_util.go" %}}
{{% include file="assets\homepage\go\lambda_util.go" %}}
```

{{% /tab %}}
Expand Down
10 changes: 5 additions & 5 deletions web/content/cloud_computing/aws/canonical_requests/signing.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ts-node signing.ts $AWS_SECRET_KEY us-west-1 ssm "Hello World!"
{{% tab name="signing.ts" %}}

```ts
{{% include file="code\can_req\ts\signing.ts" %}}
{{% include file="assets\can_req\ts\signing.ts" %}}
```

{{% /tab %}}
Expand All @@ -96,7 +96,7 @@ node signing.js $AWS_SECRET_KEY us-west-1 ssm "Hello World!"
{{% tab name="signing.js" %}}

```js
{{% include file="code\can_req\js\signing.js" %}}
{{% include file="assets\can_req\js\signing.js" %}}
```

{{% /tab %}}
Expand All @@ -118,7 +118,7 @@ python3 signing.py $AWS_SECRET_KEY us-west-1 ssm "Hello World!"
{{% tab name="signing.py" %}}

```py
{{% include file="code\can_req\py\signing.py" %}}
{{% include file="assets\can_req\py\signing.py" %}}
```

{{% /tab %}}
Expand All @@ -140,14 +140,14 @@ go run signing_driver.go signing.go $AWS_SECRET_KEY us-west-1 ssm "Hello World!"
{{% tab name="signing.go" %}}

```go
{{% include file="code\can_req\go\signing.go" %}}
{{% include file="assets\can_req\go\signing.go" %}}
```

{{% /tab %}}
{{% tab name="signing_driver.go" %}}

```go
{{% include file="code\can_req\go\signing_driver.go" %}}
{{% include file="assets\can_req\go\signing_driver.go" %}}
```

{{% /tab %}}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading