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

Initial deployment configuration #3

Merged
merged 31 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b166e96
Add ADR for initial deployment choices.
danielnaab Sep 20, 2023
0be81f5
Add cloud.gov pages build (I don't expect it to work with pnpm)
danielnaab Sep 20, 2023
07d5d1e
Try to install pnpm in the container
danielnaab Sep 20, 2023
853d368
Install dependencies with pnpm after the cloud.gov pages initialization
danielnaab Sep 20, 2023
5b5d5e0
Use "pnpm i" instead of "pnpm ci" (which isn't implemented in pnpm) i…
danielnaab Sep 20, 2023
f8b545a
Tweak pnpm / Cloud.gov Pages hack
danielnaab Sep 20, 2023
b76ba23
Try wiping out the Cloud.gov dependencies before manually installing.
danielnaab Sep 20, 2023
ff053d7
Update Vite config to handle a BASEURL.
danielnaab Sep 20, 2023
23050aa
Remove unused script
danielnaab Sep 20, 2023
3af9082
Turn off Cloud.gov Pages build container caching.
danielnaab Sep 20, 2023
4aa1c9d
Add a footer and links to the Github repository
danielnaab Sep 20, 2023
dcd134e
Remove unused "infra" package reference.
danielnaab Sep 21, 2023
260b657
Initial cloud.gov docassemble configuration. NOTE: This is failing to…
danielnaab Sep 21, 2023
3edb492
Initial attempt at docassemble docker configuration, to be pared down.
danielnaab Sep 21, 2023
bd10f1e
Pare down docker config
danielnaab Sep 21, 2023
32569b2
Fill in Docassemble client API and corresponding CLI commands.
danielnaab Oct 3, 2023
b0a0d34
In Github action, update pnpm version to 8.
danielnaab Oct 3, 2023
229118e
Tweak tests to get passing
danielnaab Oct 3, 2023
811ad63
Label docassemble tests as integration tests, so they don't get run b…
danielnaab Oct 3, 2023
70c3685
Add scaffold for Terraform CDK project.
danielnaab Oct 4, 2023
4d99f41
Add ADR for Terraform usage.
danielnaab Oct 4, 2023
9a77ccc
Add initial docassemble deploy to AWS Lightsail.
danielnaab Oct 5, 2023
ef68706
Put userData script in root namespace
danielnaab Oct 6, 2023
14b6479
Use recommended medium-sized instance.
danielnaab Oct 6, 2023
670432e
Add recreate.sh to force-rebuild the docassemble instance.
danielnaab Oct 6, 2023
1581c97
Remove currently unused deps to save build container space
danielnaab Oct 11, 2023
a157d38
Hack in skip cli build step
danielnaab Oct 12, 2023
b459936
Add Turborepo for more managable builds.
danielnaab Oct 12, 2023
65fe969
Add ADR for pnpm and Turborepo.
danielnaab Oct 12, 2023
6600261
Add Turborepo to Cloud.gov pages build.
danielnaab Oct 12, 2023
82507ad
Add turbo to project dependencies
danielnaab Oct 12, 2023
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: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 7
version: 8
run_install: false

- name: Get pnpm store directory
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
.env
*.code-workspace
_site
.turbo/
.vscode/
coverage/
node_modules/
5 changes: 3 additions & 2 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"license": "CC0",
"main": "src/index.ts",
"scripts": {
"build": "tsc -p .",
"build": "echo 'skipping...' #tsc -p .",
"cli": "ts-node src/index.ts",
"test": "vitest run --coverage"
},
"dependencies": {
"@atj/interviews": "workspace:*",
"@atj/dependency-graph": "workspace:*",
"commander": "^9.4.1"
"@atj/docassemble": "workspace:*",
"commander": "^11.0.0"
}
}
9 changes: 7 additions & 2 deletions apps/cli/src/cli-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ describe('cli controller', () => {
const ctx = {
console: mock<Console>({ log: vi.fn() }),
workspaceRoot: '.',
docassemble: {
fetch: fetch,
apiUrl: '',
apiKey: '',
},
};
const app = CliController(ctx);
await app.parseAsync(['node', 'script-name', 'hello-world', 'aardvark']);
expect(ctx.console.log).toHaveBeenCalledWith('Hello, aardvark!');
await app.parseAsync(['node.js', 'dist/index.js', 'hello']);
expect(ctx.console.log).toHaveBeenCalledWith('Hello!');
});
});
46 changes: 40 additions & 6 deletions apps/cli/src/cli-controller.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,61 @@
import { Command } from 'commander';

import { createDependencyGraph } from '@atj/dependency-graph';
import { DocassembleClient, DocassembleClientContext } from '@atj/docassemble';

type Context = {
console: Console;
workspaceRoot: string;
docassemble: DocassembleClientContext;
};

export const CliController = (ctx: Context) => {
const cli = new Command();
const cli = new Command().description(
'CLI to interact with the ATJ workspace'
);

cli
.command('hello-world <echo-value>')
.description('hello world')
.action(async echoValue => {
await createDependencyGraph(ctx.workspaceRoot);
ctx.console.log(`Hello, ${echoValue}!`);
.command('hello')
.description('say hello')
.action(() => {
ctx.console.log('Hello!');
});

cli
.command('create-workspace-graph')
.description('create a dependency graph of projects in the workspace')
.action(async () => {
await createDependencyGraph(ctx.workspaceRoot);
ctx.console.log('wrote workspace dependency graph');
});

const docassemble = cli
.command('docassemble')
.description('docassemble commands');

docassemble
.command('populate')
.description('populate a docassemble instance with test data')
.option(
'-r, --repository',
'repository to populate from',
'https://github.com/SuffolkLITLab/docassemble-MassAccess'
)
.option('-b, --branch', 'branch of git repository to populate from', 'main')
.action(async ({ repository, branch }) => {
const client = new DocassembleClient(ctx.docassemble);
const result = await client.addPackage(repository, branch);
ctx.console.log('populated docassemble instance', result);
});

docassemble
.command('list-interviews')
.description('list docassemble interviews')
.action(async () => {
const client = new DocassembleClient(ctx.docassemble);
const interviews = await client.getInterviews();
ctx.console.log('populated docassemble instance');
});

return cli;
};
11 changes: 10 additions & 1 deletion apps/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { join } from 'path';
import process from 'process';
import { CliController } from './cli-controller';

// This should map to the directory containing the package.json.
// By convention, assume that the originating process was run from the root
// directory.
const workspaceRoot = join(process.cwd(), '../../');

const app = CliController({ console, workspaceRoot });
const app = CliController({
console,
workspaceRoot,
docassemble: {
fetch,
apiUrl: 'http://localhost:8011',
apiKey: process.env.VITE_DOCASSEMBLE_API_KEY || '',
},
});
app.parseAsync(process.argv).then(() => console.log('Done'));
10 changes: 2 additions & 8 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@
"scripts": {
"build": "tsc && vite build",
"dev": "vite",
"preview": "vite preview",
"test": "vitest"
"preview": "vite preview"
},
"dependencies": {
"@atj/docassemble": "workspace:*",
"@atj/documents": "workspace:*",
"@atj/interviews": "workspace:*",
"@axe-core/playwright": "^4.7.3",
"@uswds/uswds": "^3.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@playwright/test": "^1.37.1",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.15",
"playwright": "^1.37.1",
"sass": "^1.66.1",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vitest": "^0.34.4"
"vite": "^4.4.9"
}
}
90 changes: 0 additions & 90 deletions apps/frontend/playwright.config.ts

This file was deleted.

17 changes: 17 additions & 0 deletions apps/frontend/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Header } from './components/header';
import { Footer } from './components/footer';
import { UsaBanner } from './components/usa-banner';
import { HomePage } from './routes';
import { useAppContext } from './context';

export const App = () => {
const context = useAppContext();
return (
<div className="App">
<UsaBanner />
<Header />
<HomePage />
<Footer github={context.github} />
</div>
);
};
53 changes: 53 additions & 0 deletions apps/frontend/src/components/footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { type GithubRepository, getBranchTreeUrl } from '../lib/github';

type FooterProps = {
github: GithubRepository;
};

export const Footer = (props: FooterProps) => {
return (
<footer className="usa-footer usa-footer--slim">
<div className="grid-container usa-footer__return-to-top">
<a href="#">Return to top</a>
</div>
<div className="usa-footer__primary-section">
<div className="usa-footer__primary-container grid-row">
<div className="mobile-lg:grid-col-8">
<nav className="usa-footer__nav" aria-label="Footer navigation,">
<ul className="grid-row grid-gap">
<li
className="
mobile-lg:grid-col-6
desktop:grid-col-auto
usa-footer__primary-content
"
>
<a
className="usa-footer__primary-link"
href="https://10x.gsa.gov/"
>
10x
</a>
</li>
<li
className="
mobile-lg:grid-col-6
desktop:grid-col-auto
usa-footer__primary-content
"
>
<a
className="usa-footer__primary-link"
href={getBranchTreeUrl(props.github, true)}
>
Github repository
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</footer>
);
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { createContext, useContext } from 'react';
import { GithubRepository } from './lib/github';

export interface Backend {
helloWorld(echoValue: string): string;
}

export interface Context {
backend: Backend;
github: GithubRepository;
}

export const AppContext = createContext<Context>({
backend: {} as Backend,
github: {} as GithubRepository,
});

export const useAppContext = () => {
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion apps/frontend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createAppRoot } from './views/main';
import { createAppRoot } from './main';

createAppRoot(document.getElementById('root') as HTMLElement, {
backend: {
helloWorld: (str: string) => str,
},
github: import.meta.env.GITHUB,
});
27 changes: 27 additions & 0 deletions apps/frontend/src/lib/github.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export type GithubRepository = {
owner: string;
repository: string;
branch: string;
commit: string;
};

export const DEFAULT_REPOSITORY: GithubRepository = {
owner: 'gsa-tts',
repository: 'atj-platform',
branch: 'main',
commit: 'main',
};

export const getBranchTreeUrl = (
github: GithubRepository,
useDefaultShortForm = true
) => {
if (useDefaultShortForm && github.branch === DEFAULT_REPOSITORY.branch) {
return `https://github.com/${github.owner}/${github.repository}`;
}
return `https://github.com/${github.owner}/${github.repository}/tree/${github.branch}`;
};

export const getNewIssueUrl = (github: GithubRepository) => {
return `https://github.com/${github.owner}/${github.repository}/issues/new/choose`;
};
File renamed without changes.
Loading
Loading