Skip to content
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

Dependency and workflow updates #256

Merged
merged 11 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/delete-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Delete Review App

on:
pull_request:
types: [closed]

permissions:
id-token: write
contents: read

concurrency:
group: ${{ github.event.pull_request.number }}

jobs:
check-secret-access:
runs-on: ubuntu-latest
outputs:
allowed: ${{ steps.check-secret.outputs.allowed }}
steps:
- name: Test for secrets access
id: check-secret
shell: bash
run: |
unset allowed
if [ "${{ secrets.TEST_SECRETS_ACCESS }}" != '' ]; then
echo "allowed=true" >> $GITHUB_OUTPUT;
else
echo "allowed=false" >> $GITHUB_OUTPUT;
fi

delete:
runs-on: [k8s-public]
container:
image: registry.gitlab.com/cmmarslender/kubectl-helm:v3
needs:
- check-secret-access
if: needs.check-secret-access.outputs.allowed == 'true'
steps:
- uses: actions/checkout@v3

- name: Vault Login
uses: Chia-Network/actions/vault/login@main
with:
vault_url: ${{ secrets.VAULT_URL }}
role_name: github-chialisp-web

- name: Get secrets from vault
uses: hashicorp/vault-action@v2
with:
url: ${{ secrets.VAULT_URL }}
token: ${{ env.VAULT_TOKEN }}
secrets: |
secret/data/fmt/k8s/fremont-public api_server_url | K8S_API_SERVER_URL;

- name: Login to k8s cluster
uses: Chia-Network/actions/vault/k8s-login@main
with:
vault_url: ${{ secrets.VAULT_URL }}
vault_token: ${{ env.VAULT_TOKEN }}
backend_name: fremont-public
role_name: github-actions
cluster_url: ${{ env.K8S_API_SERVER_URL }}

- name: Helm Uninstall
env:
REVIEW_SLUG: ${{ github.event.pull_request.number }}
run: |
helm uninstall -n "chialisp-web" "chialisp-web-$REVIEW_SLUG"
35 changes: 20 additions & 15 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@ name: Deploy to pages on trunk
on:
push:
branches:
- "main"
- 'main'

jobs:
deploy:
runs-on: ubuntu-latest
container: node:17-alpine
container: node:18-alpine
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: "Install deps"
run: |
apk add python3 make g++ git
yarn

- name: "yarn deploy"
run: |
git config --global user.name 'ChiaAutomation'
git config --global user.email '[email protected]'
GIT_USER=ChiaAutomation GIT_PASS=${{ github.token }} yarn deploy
- name: 'Install deps'
run: |
apk add python3 make g++ git
- name: Checkout Code
uses: actions/checkout@v3
- name: 'npm install and build'
run: |
npm ci
npm install
npm run build
- name: 'npm deploy'
run: |
# postBuffer documented at: https://git-scm.com/docs/git-config#Documentation/git-config.txt-httppostBuffer
# Needed due to commit/push errors over https related to the remote hanging up unexpectedly
git config --global http.postBuffer 10000000
git config --global user.name 'ChiaAutomation'
git config --global user.email '[email protected]'
GIT_USER=ChiaAutomation GIT_PASS=${{ github.token }} npm run deploy
144 changes: 144 additions & 0 deletions .github/workflows/deploy-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Deploy Review App on PR

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
id-token: write
contents: read
packages: write

concurrency:
group: ${{ github.event.pull_request.number }}

jobs:
check-secret-access:
runs-on: ubuntu-latest
outputs:
allowed: ${{ steps.check-secret.outputs.allowed }}
steps:
- name: Test for secrets access
id: check-secret
shell: bash
run: |
unset allowed
if [ "${{ secrets.TEST_SECRETS_ACCESS }}" != '' ]; then
echo "allowed=true" >> $GITHUB_OUTPUT;
else
echo "allowed=false" >> $GITHUB_OUTPUT;
fi

build:
runs-on: ubuntu-latest
container: node:18-alpine
steps:
- name: 'Install deps'
run: |
apk add python3 make g++ git
- name: Checkout Code
uses: actions/checkout@v3
- name: 'npm install and build'
run: |
npm install
npm ci
npm run build
- name: Upload build to artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: build

package:
runs-on: ubuntu-latest
needs:
- build
- check-secret-access
if: needs.check-secret-access.outputs.allowed == 'true'
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Download build from artifacts
uses: actions/download-artifact@v3
with:
name: build
path: ./build
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=sha,format=long
- name: Build Docker Container
uses: docker/build-push-action@v3
with:
context: .
Starttoaster marked this conversation as resolved.
Show resolved Hide resolved
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}

deploy:
name: Deploy
needs:
- package
- check-secret-access
if: needs.check-secret-access.outputs.allowed == 'true'
runs-on: [k8s-public]
container:
image: registry.gitlab.com/cmmarslender/kubectl-helm:v3
environment:
name: Review ${{ github.event.pull_request.number }}
url: https://${{ github.event.pull_request.number }}.chialisp-web.chia.net
steps:
- uses: actions/checkout@v3

- name: Vault Login
uses: Chia-Network/actions/vault/login@main
with:
vault_url: ${{ secrets.VAULT_URL }}
role_name: github-chialisp-web

- name: Get secrets from vault
uses: hashicorp/vault-action@v2
with:
url: ${{ secrets.VAULT_URL }}
token: ${{ env.VAULT_TOKEN }}
secrets: |
secret/data/fmt/k8s/fremont-public api_server_url | K8S_API_SERVER_URL;

- name: Login to k8s cluster
uses: Chia-Network/actions/vault/k8s-login@main
with:
vault_url: ${{ secrets.VAULT_URL }}
vault_token: ${{ env.VAULT_TOKEN }}
backend_name: fremont-public
role_name: github-actions
cluster_url: ${{ env.K8S_API_SERVER_URL }}

- name: Install certificate
run: |
kubectl create namespace chialisp-web || true
kubectl apply -n chialisp-web -f ./k8s/certificate.yaml

- uses: Chia-Network/actions/helm/deploy@main
env:
DOCKER_TAG: "sha-${{ github.sha }}"
REVIEW_SLUG: ${{ github.event.pull_request.number }}
with:
namespace: "chialisp-web"
app_name: "chialisp-web-${{ env.REVIEW_SLUG }}"
helm_chart_repo: "https://chia-network.github.io/helm-charts"
helm_chart: "generic"
helm_values: "./k8s/review.yaml"
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chialisp.com
19 changes: 4 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
FROM node:16

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

RUN ./node_modules/yarn/bin/yarn

CMD [ "yarn", "start" ]
FROM nginx:stable-alpine
COPY build /usr/share/nginx/html
EXPOSE 80
CMD nginx -g "daemon off;"
40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,44 @@
# Website

This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator.
This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator, and deployed with Github Pages.

### Installation

```
$ npm install --local yarn
$ ./node_modules/yarn/bin/yarn
$ npm install
```

### Local Development

```
$ yarn start
$ npm start
```

This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Docker Local Development
### Build

```
$ docker-compose up
$ npm run build
```

You can also install and start local development server using Docker.

### Local Development notes

`yarn` & `docusaurus` interpret text within angle-brackets, so be careful when using them, if you are editing the .md files directly.

If you are logged in to your github account, you can edit a page right on chialisp.com, by clicking on the "Edit this page" link at the bottom of the article. That will allow you to edit the page, and submit a pull request against the underlying markdown file.
This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Build
### Serve

```
$ yarn build
$ npm run serve
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.
This command serves the static content in the `build` directory.

### Deployment
### Commands run in github CI

```
$ GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
```
These are the commands being run in the github CI, run them all locally in this order to ensure there are no issues building and serving the content prior to submitting a pr:

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
```
$ npm install
$ npm ci
$ npm run build
$ npm run serve
```
12 changes: 0 additions & 12 deletions docker-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/clvm.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: CLVM
slug: /clvm
---

import Runnable from '../src/components/Runnable.tsx';
import Runnable from '@site/src/components/Runnable.tsx';
import Program from 'clvm-lib';

Chialisp is compiled to bytecode, which is executed on the Chialisp Virtual Machine. CLVM is as minimal as possible, and doesn't have direct support for language constructs such as functions, constants, and modules.
Expand Down
2 changes: 1 addition & 1 deletion docs/costs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Costs
slug: /costs
---

import Runnable from '../src/components/Runnable.tsx';
import Runnable from '@site/src/components/Runnable.tsx';

Every operator has a cost associated with it. Additionally, there can be a separate cost dependent on the number of arguments or bytes used when calling it.

Expand Down
2 changes: 1 addition & 1 deletion docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Debugging
slug: /debugging
---

import Runnable from '../src/components/Runnable.tsx';
import Runnable from '@site/src/components/Runnable.tsx';

Debugging Chialisp at times can be frustrating. Due to the nature of how it handles data structures, programs will often continue on with incorrect values only to error out at a later spot that gives no clue to the initial breakage. For example, a variable typo will often result in the variable being evaluated as a string, and if that gets hashed into something it's impossible to tell.

Expand Down
Loading
Loading