Skip to content

Commit

Permalink
Merge pull request #2 from fluent-ci-templates/feat/aws-azure-circleci
Browse files Browse the repository at this point in the history
feat: add yaml generators for circleci, aws, azure and gitlab
  • Loading branch information
tsirysndr authored Aug 20, 2023
2 parents 90892a4 + e7862e2 commit 33d9b0a
Show file tree
Hide file tree
Showing 17 changed files with 309 additions and 23 deletions.
57 changes: 51 additions & 6 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 22 additions & 6 deletions fixtures/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# Do not edit this file directly. It is generated by Fluent GitLab CI

codecov:
.docker:
image: denoland/deno:alpine
services:
- docker:${DOCKER_VERSION}-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_VERIFY: "1"
DOCKER_TLS_CERTDIR: /certs
DOCKER_CERT_PATH: /certs/client
DOCKER_DRIVER: overlay2
DOCKER_VERSION: 20.10.16

.dagger:
extends: .docker
before_script:
- |
deno install -A -r https://cli.fluentci.io -n fluentci
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
sudo mv bin/dagger /usr/local/bin
dagger version
- apk add docker-cli curl unzip
- deno install -A -r https://cli.fluentci.io -n fluentci
- curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
- mv bin/dagger /usr/local/bin
- dagger version

codecov:
extends: .dagger
script:
- dagger run fluentci codecov_pipeline

22 changes: 22 additions & 0 deletions fixtures/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_azure_pipelines

trigger:
- master
pool:
name: Default
vmImage: ubuntu-latest
steps:
- script: |
curl -fsSL https://deno.land/x/install/install.sh | sh
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
displayName: Install Deno
- script: deno install -A -r https://cli.fluentci.io -n fluentci
displayName: Setup Fluent CI CLI
- script: |
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
sudo mv bin/dagger /usr/local/bin
dagger version
displayName: Setup Dagger
- script: dagger run fluentci codecov_pipeline
displayName: Upload Coverage
19 changes: 19 additions & 0 deletions fixtures/buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_aws_codepipeline

version: 0.2
phases:
install:
commands:
- curl -fsSL https://deno.land/x/install/install.sh | sh
- export DENO_INSTALL="$HOME/.deno"
- export PATH="$DENO_INSTALL/bin:$PATH"
- deno install -A -r https://cli.fluentci.io -n fluentci
- curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
- mv bin/dagger /usr/local/bin
- dagger version
build:
commands:
- dagger run fluentci codecov_pipeline
post_build:
commands:
- echo Build completed on `date`
2 changes: 1 addition & 1 deletion fixtures/codecov-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Do not edit this file directly. It is generated by Fluent Github Actions
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_github_actions

name: Codecov
on:
Expand Down
26 changes: 26 additions & 0 deletions fixtures/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_circleci

version: 2.1
jobs:
codecov:
steps:
- checkout
- run: sudo apt-get update && sudo apt-get install -y curl unzip
- run: |
curl -fsSL https://deno.land/x/install/install.sh | sh
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
- run: deno install -A -r https://cli.fluentci.io -n fluentci
- run: |
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
sudo mv bin/dagger /usr/local/bin
dagger version
- run:
name: Upload Coverage
command: dagger run fluentci codecov_pipeline
machine:
image: ubuntu-2004:2023.07.1
workflows:
dagger:
jobs:
- codecov
5 changes: 4 additions & 1 deletion import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"imports": {
"@dagger.io/dagger": "https://esm.sh/v128/*@dagger.io/dagger@0.8.1",
"fluent_gitlab_ci": "https://deno.land/x/fluent_gitlab_ci@v0.3.2/mod.ts",
"fluent_github_actions": "https://deno.land/x/fluent_github_actions@v0.1.2/mod.ts",
"fluent_github_actions": "https://deno.land/x/fluent_github_actions@v0.2.1/mod.ts",
"fluent_circleci": "https://deno.land/x/fluent_circleci@v0.2.4/mod.ts",
"fluent_azure_pipelines": "https://deno.land/x/fluent_azure_pipelines@v0.1.5/mod.ts",
"fluent_aws_codepipeline": "https://deno.land/x/fluent_aws_codepipeline@v0.2.3/mod.ts",
"url": "node:url",
"readline": "node:readline",
"process": "node:process",
Expand Down
24 changes: 24 additions & 0 deletions src/aws/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { BuildSpec } from "fluent_aws_codepipeline";

export function generateYaml(): BuildSpec {
const buildspec = new BuildSpec();
buildspec
.phase("install", {
commands: [
"curl -fsSL https://deno.land/x/install/install.sh | sh",
'export DENO_INSTALL="$HOME/.deno"',
'export PATH="$DENO_INSTALL/bin:$PATH"',
"deno install -A -r https://cli.fluentci.io -n fluentci",
"curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh",
"mv bin/dagger /usr/local/bin",
"dagger version",
],
})
.phase("build", {
commands: ["dagger run fluentci codecov_pipeline"],
})
.phase("post_build", {
commands: ["echo Build completed on `date`"],
});
return buildspec;
}
9 changes: 9 additions & 0 deletions src/aws/config_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
import { generateYaml } from "./config.ts";

Deno.test(function generateAWSCodePipelineTest() {
const buildspec = generateYaml();
const actual = buildspec.toString();
const expected = Deno.readTextFileSync("./fixtures/buildspec.yml");
assertEquals(actual, expected);
});
3 changes: 3 additions & 0 deletions src/aws/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { generateYaml } from "./config.ts";

generateYaml().save("buildspec.yml");
41 changes: 41 additions & 0 deletions src/azure/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { AzurePipeline } from "fluent_azure_pipelines";

export function generateYaml(): AzurePipeline {
const azurePipeline = new AzurePipeline();

const installDeno = `\
curl -fsSL https://deno.land/x/install/install.sh | sh
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
`;

const setupDagger = `\
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
sudo mv bin/dagger /usr/local/bin
dagger version
`;

azurePipeline
.trigger(["master"])
.pool({
name: "Default",
vmImage: "ubuntu-latest",
})
.step({
script: installDeno,
displayName: "Install Deno",
})
.step({
script: "deno install -A -r https://cli.fluentci.io -n fluentci",
displayName: "Setup Fluent CI CLI",
})
.step({
script: setupDagger,
displayName: "Setup Dagger",
})
.step({
script: "dagger run fluentci codecov_pipeline",
displayName: "Upload Coverage",
});
return azurePipeline;
}
9 changes: 9 additions & 0 deletions src/azure/config_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
import { generateYaml } from "./config.ts";

Deno.test(function generateAzurePipelinesTest() {
const azurepipelines = generateYaml();
const actual = azurepipelines.toString();
const expected = Deno.readTextFileSync("./fixtures/azure-pipelines.yml");
assertEquals(actual, expected);
});
3 changes: 3 additions & 0 deletions src/azure/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { generateYaml } from "./config.ts";

generateYaml().save("azure-pipeline.yml");
37 changes: 37 additions & 0 deletions src/circleci/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { CircleCI, Job } from "fluent_circleci";

export function generateYaml(): CircleCI {
const circleci = new CircleCI();

const codecov = new Job().machine({ image: "ubuntu-2004:2023.07.1" }).steps([
"checkout",
{
run: "sudo apt-get update && sudo apt-get install -y curl unzip",
},
{
run: `\
curl -fsSL https://deno.land/x/install/install.sh | sh
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"`,
},
{
run: "deno install -A -r https://cli.fluentci.io -n fluentci",
},
{
run: `\
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
sudo mv bin/dagger /usr/local/bin
dagger version`,
},
{
run: {
name: "Upload Coverage",
command: "dagger run fluentci codecov_pipeline",
},
},
]);

circleci.jobs({ codecov }).workflow("dagger", ["codecov"]);

return circleci;
}
9 changes: 9 additions & 0 deletions src/circleci/config_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
import { generateYaml } from "./config.ts";

Deno.test(function generateCircleCITest() {
const circleci = generateYaml();
const actual = circleci.toString();
const expected = Deno.readTextFileSync("./fixtures/config.yml");
assertEquals(actual, expected);
});
3 changes: 3 additions & 0 deletions src/circleci/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { generateYaml } from "./config.ts";

generateYaml().save(".circleci/config.yml");
35 changes: 26 additions & 9 deletions src/gitlab/config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
import { GitlabCI, Job } from "fluent_gitlab_ci";

export function generateYaml(): GitlabCI {
const setupDagger = `
deno install -A -r https://cli.fluentci.io -n fluentci
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
sudo mv bin/dagger /usr/local/bin
dagger version`;
const docker = new Job()
.image("denoland/deno:alpine")
.services(["docker:${DOCKER_VERSION}-dind"])
.variables({
DOCKER_HOST: "tcp://docker:2376",
DOCKER_TLS_VERIFY: "1",
DOCKER_TLS_CERTDIR: "/certs",
DOCKER_CERT_PATH: "/certs/client",
DOCKER_DRIVER: "overlay2",
DOCKER_VERSION: "20.10.16",
});

const dagger = new Job().extends(".docker").beforeScript(
`
apk add docker-cli curl unzip
deno install -A -r https://cli.fluentci.io -n fluentci
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
mv bin/dagger /usr/local/bin
dagger version
`
);

const codecov = new Job()
.beforeScript(setupDagger, {
multiline: true,
})
.extends(".dagger")
.script("dagger run fluentci codecov_pipeline");

return new GitlabCI().addJob("codecov", codecov);
return new GitlabCI()
.addJob(".docker", docker)
.addJob(".dagger", dagger)
.addJob("codecov", codecov);
}

0 comments on commit 33d9b0a

Please sign in to comment.