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

fix validate-example.sh #53

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions .ci/build-examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

cd $PWD
go get github.com/go-ole/go-ole/oleutil@v1.3.0

:> build_errors
find $PWD -maxdepth 2 -mindepth 1 -not -path '*/\.*' -type d -exec sh -c "cd {}; echo building {}; go build -tags=test main.go" 2>>build_log \;
grep -v "^go: " build_log | grep -v main.go > build_errors
if [[ $(wc -l build_errors | awk '{print $1}') == "0" ]]; then
exit 0
fi
echo BUILD ERRORS:
cat build_errors
echo END OF BUILD ERRORS.
exit 1
8 changes: 4 additions & 4 deletions .ci/validate-examples.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash
:> errors
output=$(find ../_examples -maxdepth 2 -mindepth 2 ! -name "metered" ! -name "offline" ! -name "metered-non-persistent-cache" ! -name "usage-logs" -print0 | xargs -0 -I{} sh -c "cd {}; echo running {}; ./main")
output=$(find ../ -maxdepth 2 -mindepth 1 -not -path '*/\.*' -type d ! -name "metered" ! -name "offline" ! -name "metered-non-persistent-cache" ! -name "usage-logs" -print0 | xargs -0 -I{} sh -c "cd {}; echo running {}; ./main")
if [ $? -ne 0 ]; then
echo $output >> errors
fi
export PATH=$PATH:$HOME/dotnet
find ../_examples -name "*.docx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} docx \;
find ../_examples -name "*.xlsx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} xlsx \;
find ../_examples -name "*.pptx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} pptx \;
find ../ -name "*.docx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} docx \;
find ../ -name "*.xlsx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} xlsx \;
find ../ -name "*.pptx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} pptx \;
echo Errors: $(wc -l errors)
if [[ $(wc -l errors | awk '{print $1}') == "0" ]]; then
exit 0
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: UniOffice CI
name: UniOffice Examples CI

on:
push:
Expand Down Expand Up @@ -34,7 +34,7 @@ jobs:
wget https://download.visualstudio.microsoft.com/download/pr/4e3b04aa-c015-4e06-a42e-05f9f3c54ed2/74d1bb68e330eea13ecfc47f7cf9aeb7/dotnet-sdk-8.0.404-linux-x64.tar.gz
tar -xf dotnet-sdk-8.0.404-linux-x64.tar.gz

- name: test
- name: Test and validate examples
run: |
export REPO=$PWD
cd $REPO/.ci
Expand All @@ -44,7 +44,7 @@ jobs:
cd $REPO/.ci/openxml-validator
$HOME/dotnet/dotnet build --configuration Release
cd $REPO
./build_examples.sh
./.ci/build-examples.sh
cd $REPO/.ci
./validate-examples.sh
if [ $? -ne 0 ]
Expand Down
9 changes: 1 addition & 8 deletions document/comment-list/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ func init() {
}

func main() {
if len(os.Args) < 2 {
fmt.Printf("Syntax: go run main.go input.docx\n")
os.Exit(1)
}

inputPath := os.Args[1]

doc, err := document.Open(inputPath)
doc, err := document.Open("sample.docx")
if err != nil {
log.Fatalf("error opening document: %s", err)
}
Expand Down
Binary file added document/comment-list/sample.docx
Binary file not shown.
16 changes: 2 additions & 14 deletions document/comment-remove/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"fmt"
"log"
"os"
"strconv"

"github.com/unidoc/unioffice/v2/common/license"
"github.com/unidoc/unioffice/v2/document"
Expand All @@ -26,26 +25,15 @@ func init() {
}

func main() {
if len(os.Args) < 3 {
fmt.Printf("Syntax: go run main.go input.docx comment_id\n")
os.Exit(1)
}

inputPath := os.Args[1]
commentId, err := strconv.Atoi(os.Args[2])
if err != nil {
log.Fatalf("error parsing comment id: %s", err)
}

doc, err := document.Open(inputPath)
doc, err := document.Open("sample.docx")
if err != nil {
log.Fatalf("error opening document: %s", err)
}
defer doc.Close()

listComments(doc)

if sucess := doc.RemoveComment(int64(commentId)); !sucess {
if ok := doc.RemoveComment(int64(2)); !ok {
fmt.Println("Failed removing comment")

return
Expand Down
Binary file added document/comment-remove/sample.docx
Binary file not shown.
14 changes: 2 additions & 12 deletions document/node-remove/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package main

import (
"fmt"
"log"
"os"

Expand All @@ -20,16 +19,7 @@ func init() {
}

func main() {
args := os.Args
if len(args) < 2 {
fmt.Printf("Usage %s go run main.go input.docx output.docx", os.Args[0])
return
}

inputPath := args[1]
outputPath := args[2]

doc, err := document.Open(inputPath)
doc, err := document.Open("sample.docx")
if err != nil {
log.Fatalf("error opening document: %s", err)
}
Expand All @@ -46,7 +36,7 @@ func main() {
}
}

err = doc.SaveToFile(outputPath)
err = doc.SaveToFile("output.docx")
if err != nil {
panic(err)
}
Expand Down
Binary file modified document/template-with-header/letter_template.docx
Binary file not shown.
Binary file added document/use-template/use-template.docx
Binary file not shown.
13 changes: 2 additions & 11 deletions spreadsheet/line-chart-from-csv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ func init() {
}

func main() {
args := os.Args
if len(args) < 2 {
fmt.Printf("Usage %s go run main.go input.csv output.xlsx", os.Args[0])
return
}

inputPath := args[1]
outputPath := args[2]

sliceData, err := readCsv(inputPath)
sliceData, err := readCsv("example-data.csv")
if err != nil {
log.Fatalf("error reading csv: %s", err)
}
Expand Down Expand Up @@ -99,7 +90,7 @@ func main() {
log.Fatalf("error validating sheet: %s", err)
}

if err := ss.SaveToFile(outputPath); err != nil {
if err := ss.SaveToFile("output.xlsx"); err != nil {
log.Fatalf("error saving: %s", err)
}
}
Expand Down
Binary file modified spreadsheet/line-chart-from-csv/output.xlsx
Binary file not shown.
Binary file modified spreadsheet/multiple-charts-from-csv/charts-from-csv.xlsx
Binary file not shown.
Loading