Skip to content

Commit

Permalink
CI Updates (#154)
Browse files Browse the repository at this point in the history
* Auto format

* Consolidated dupe workflow files

* Make CI code DRY

* Autoformat

* Remove unused env var

* Update aws profile name to the more appropriate oxheadalpha_tempKubernetesAdmin

* Update action version bec of deprecation warnings
  • Loading branch information
harryttd committed Aug 24, 2023
1 parent 58d158f commit 31a8806
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 173 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Pulumi Preview
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
preview:
name: Preview
uses: ./.github/workflows/setup.yml
secrets: inherit
with:
pulumi-command: preview
53 changes: 0 additions & 53 deletions .github/workflows/pull-request.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/push-to-main.yml

This file was deleted.

59 changes: 8 additions & 51 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,20 @@
name: Publish teztnets
name: Publish Teztnets

on:
push:
tags:
- 'v*'
- "v*"
schedule:
# update the deployment every Monday at 0:00 UTC
- cron: '0 0 * * *'
- cron: "0 0 * * *"

jobs:
up:
name: up
runs-on: ubuntu-latest
outputs:
networks: ${{ steps.pup.outputs.networks }}
teztnets: ${{ steps.pup.outputs.teztnets }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: true
token : ${{ secrets.ACCESS_TOKEN }}

- uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: tempKubernetesAdmin


- name: Add profile credentials to ~/.aws/credentials
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile oxheadalpha
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile oxheadalpha
- name: Install Pulumi CLI
uses: pulumi/[email protected]
with:
pulumi-version: 3.32.1
- run: npm install

- uses: pulumi/actions@v3
id: pup
with:
command: up
stack-name: tqtezos/teztnets/teztnets
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
name: Up
uses: ./.github/workflows/setup.yml
secrets: inherit
with:
pulumi-command: up

build:
needs: up
Expand All @@ -81,8 +40,6 @@ jobs:
- name: generate release artifacts
run: |
python src/release.py
env:
FAUCET_RECAPTCHA_SITE_KEY: ${{secrets.FAUCET_RECAPTCHA_SITE_KEY }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Pulumi Setup
on:
workflow_call:
inputs:
pulumi-command:
required: true
type: string

jobs:
pulumi:
runs-on: ubuntu-latest
outputs:
networks: ${{ steps.pup.outputs.networks }}
teztnets: ${{ steps.pup.outputs.teztnets }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: true

- uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: tempKubernetesAdmin

- name: Add profile credentials to ~/.aws/credentials
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile oxheadalpha_tempKubernetesAdmin
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile oxheadalpha_tempKubernetesAdmin
- run: npm install

- uses: pulumi/actions@v4
id: pup
with:
command: ${{ inputs.pulumi-command }}
stack-name: tqtezos/teztnets/teztnets
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}

2 changes: 1 addition & 1 deletion Pulumi.teztnets.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
config:
aws:profile: oxheadalpha
aws:profile: oxheadalpha_tempKubernetesAdmin
aws:region: us-east-2
teztnets:aws-account-id:
secure: AAABAKrODV/Bg/UQH/m6XVe4fijcmBQ6K0ip2ywd1EKRxaVh4vfNgWytrRg=
Expand Down
69 changes: 50 additions & 19 deletions src/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,92 @@
shutil.copytree("src/website", "target/release", dirs_exist_ok=True)

teztnets = {}
with open("./teztnets.json", 'r') as teztnets_file:
with open("./teztnets.json", "r") as teztnets_file:
teztnets = json.load(teztnets_file)

networks = {}
with open("./networks.json", 'r') as networks_file:
with open("./networks.json", "r") as networks_file:
networks = json.load(networks_file)

for network_name in networks:
with open(f"target/release/{network_name}", "w") as out_file:
print(json.dumps(networks[network_name], indent = 2), file=out_file)
print(json.dumps(networks[network_name], indent=2), file=out_file)

# group by category for human rendering
# Order manually. Start with long-running.
category_desc = {
"Long-running Teztnets": "If you are not sure, pick this one.",
"Protocol Teztnets":"Testnets deployed specifically to test new Tezos protocol proposals.",
"Periodic Teztnets": "Testnets that restart regularly and track the development of the master branch of [Octez repo](https://gitlab.com/tezos/tezos/).\n \n☠️ You probably don't want this unless you are a core protocol developer." }
nested_teztnets = {"Long-running Teztnets":{}, "Protocol Teztnets":{}, "Periodic Teztnets":{}}
for k,v in teztnets.items():
"Long-running Teztnets": "If you are not sure, pick this one.",
"Protocol Teztnets": "Testnets deployed specifically to test new Tezos protocol proposals.",
"Periodic Teztnets": "Testnets that restart regularly and track the development of the master branch of [Octez repo](https://gitlab.com/tezos/tezos/).\n \n☠️ You probably don't want this unless you are a core protocol developer.",
}

nested_teztnets = {
"Long-running Teztnets": {},
"Protocol Teztnets": {},
"Periodic Teztnets": {},
}

for k, v in teztnets.items():
if v["masked_from_main_page"]:
continue
if v["category"] not in nested_teztnets:
nested_teztnets[v["category"]] = {}
nested_teztnets[v["category"]][k] = v
nested_teztnets[v["category"]][k]["activated_on"] = networks[k]["genesis"]["timestamp"].split("T")[0]
nested_teztnets[v["category"]][k]["activated_on"] = networks[k]["genesis"][
"timestamp"
].split("T")[0]

index = jinja2.Template(open("src/release_notes.md.jinja2").read()).render(
teztnets=nested_teztnets, category_desc=category_desc
)

index = jinja2.Template(open('src/release_notes.md.jinja2').read()).render(teztnets=nested_teztnets, category_desc=category_desc)
with open("target/release-notes.markdown", "w") as out_file:
print(index, file=out_file)
with open("target/release/index.markdown", "a") as out_file:
print(index, file=out_file)
with open("target/release/teztnets.json", "w") as out_file:
print(json.dumps(teztnets, indent = 2), file=out_file)
print(json.dumps(teztnets, indent=2), file=out_file)

for k,v in teztnets.items():
for k, v in teztnets.items():
if k == "mainnet":
continue

v["release"] = None
if "tezos/tezos:v" in v["docker_build"]:
v["release"] = v["docker_build"].split("tezos/tezos:")[1]
v["release"] = v["docker_build"].split("tezos/tezos:")[1]
v["docker_build_hyperlinked"] = v["docker_build"]

if v["docker_build"].startswith("tezos/tezos"):
# build from docker hub, providing a link
v["docker_build_hyperlinked"] = "[" + v['docker_build'] + "](https://hub.docker.com/r/tezos/tezos/tags?page=1&ordering=last_updated&name=" + v['docker_build'].replace('tezos/tezos:', '') + ")"

v["docker_build_hyperlinked"] = (
"["
+ v["docker_build"]
+ "](https://hub.docker.com/r/tezos/tezos/tags?page=1&ordering=last_updated&name="
+ v["docker_build"].replace("tezos/tezos:", "")
+ ")"
)

v["git_repo"] = "[email protected]:tezos/tezos.git"

readme = ""

if os.path.exists(f"{k.split('-')[0]}/README.md"):
with open(f"{k.split('-')[0]}/README.md") as readme_file:
readme = readme_file.read()
teztnet_md = jinja2.Template(open('src/teztnet_page.md.jinja2').read()).render(k=k,v=v, network_params=networks[k], readme=readme)
faucet_md = jinja2.Template(open('src/teztnet_faucet.md.jinja2').read()).render(k=k,v=v, faucet_recaptcha_site_key=os.environ["FAUCET_RECAPTCHA_SITE_KEY"])
with open(f"target/release/{v['human_name'].lower()}-about.markdown", "w") as out_file:

teztnet_md = jinja2.Template(open("src/teztnet_page.md.jinja2").read()).render(
k=k, v=v, network_params=networks[k], readme=readme
)

faucet_md = jinja2.Template(open("src/teztnet_faucet.md.jinja2").read()).render(
k=k, v=v
)

with open(
f"target/release/{v['human_name'].lower()}-about.markdown", "w"
) as out_file:
print(teztnet_md, file=out_file)

with open(f"target/release/{k}-faucet.markdown", "w") as out_file:
print(faucet_md, file=out_file)

Expand All @@ -71,4 +102,4 @@
with open(f"target/release/{alias}-faucet.markdown", "w") as out_file:
print(f"{alias} is now {k}, go to [{k}-faucet]({k}-faucet)", file=out_file)
with open(f"target/release/{alias}", "w") as out_file:
print(json.dumps(networks[k], indent = 2), file=out_file)
print(json.dumps(networks[k], indent=2), file=out_file)

0 comments on commit 31a8806

Please sign in to comment.