Skip to content

Commit

Permalink
doc(CI) exemple
Browse files Browse the repository at this point in the history
  • Loading branch information
loan-mgt committed Jan 10, 2024
1 parent e6eb15f commit e0fdb80
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 16 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ jobs:
with:
go-version: 1.17

- name: Build
- name: Build Linux binary
run: GOOS=linux GOARCH=amd64 go build -o dum-flyway-validate main.go

- name: Archive Linux artifacts
uses: actions/upload-artifact@v2
with:
name: binaries
path: dum-flyway-validate

- name: Build Windows binary
run: GOOS=windows GOARCH=amd64 go build -o dum-flyway-validate.exe main.go

- name: Archive artifacts
- name: Archive Windows artifacts
uses: actions/upload-artifact@v2
with:
name: binaries
Expand Down Expand Up @@ -56,7 +65,7 @@ jobs:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
CLI tool to validate flyway migration for CI/CD
CLI tool to validate Flyway migration for CI/CD
draft: true
prerelease: false

Expand All @@ -66,8 +75,19 @@ jobs:
echo "Release HTML URL: ${{ steps.create_release.outputs.html_url }}"
echo "Release Upload URL: ${{ steps.create_release.outputs.upload_url }}"
- name: Upload Release Asset
id: upload-release-asset
- name: Upload Linux Release Asset
id: upload-linux-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dum-flyway-validate
asset_name: dum-flyway-validate
asset_content_type: application/octet-stream

- name: Upload Windows Release Asset
id: upload-windows-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img width=200 alt="logo Dum Flyway Validate" src="doc/assets/logo.png">
<img width=200 alt="logo Dum Flyway Validate" src="doc/assets/logo.svg">

# Dum Flyway Validate

Expand Down Expand Up @@ -27,6 +27,12 @@ Dum Flyway Validate is a command-line tool to locally validate Flyway migrations
./dum-flyway-validate --migration-dir path/to/migrations --debug
```

### Specify Branch for Comparison

```bash
./dum-flyway-validate --migration-dir path/to/migrations --branch your-branch
```

## Conditions Checked

- **Modified Migration File:** Error if modified after being applied.
Expand All @@ -37,6 +43,35 @@ Dum Flyway Validate is a command-line tool to locally validate Flyway migrations

- **Renamed Migration File:** Error if renamed after being applied.

## Additional Options

- `--migration-dir`: Specifies the migration directory (default: current directory).
- `--branch`: Specifies the branch to compare against (default: empty, i.e., working directory).
- `--debug`: Enable debug mode.


## Continuous Integration Example

Here is an example of integrating Dum Flyway Validate into your CI pipeline:

```yaml
stages:
- validate

variables:
DUM_FLYWAY_VALIDATE_VERSION: "v0.2.3"
MIGRATION_DIR: "path/to/migrations"
BRANCH_TO_COMPARE: "your-branch"

validate:
stage: validate
script:
- wget https://github.com/Qypol342/dum-flyway-validate/releases/download/$DUM_FLYWAY_VALIDATE_VERSION/dum-flyway-validate
- chmod +x dum-flyway-validate
- ./dum-flyway-validate --migration-dir $MIGRATION_DIR --branch $BRANCH_TO_COMPARE
```
## Contributing
Contributions are welcome! Feel free to submit issues or pull requests.
Expand Down
Binary file removed doc/assets/logo.png
Binary file not shown.
8 changes: 8 additions & 0 deletions doc/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 1 addition & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ func init() {
}

func main() {
if flag.NArg() > 0 && (flag.Arg(0) == "--help" || flag.Arg(0) == "-h") {
printHelp()
os.Exit(0)
}


if debugMode {
fmt.Println("Debug mode enabled")
Expand Down Expand Up @@ -172,9 +169,3 @@ func isMatch(input, pattern string) bool {
return re.MatchString(input)
}

func printHelp() {
fmt.Println("Usage: dum-flyway-validate [OPTIONS]")
fmt.Println(" --migration-dir Specify the migration directory (default: current directory)")
fmt.Println(" --debug Enable debug mode")
fmt.Println(" --help, -h Show this help message")
}

0 comments on commit e0fdb80

Please sign in to comment.